How can i checked the checkbox if the data is already in the database as selected by user ? For normal html, i can use checked , however, im using javascript for this one. is there any way to edit the html instead of the javascript ?
<td><div align="center"><span class="formlist">
<select id="plant" name="plant[]" class="form-control" multiple="multiple">
<?php
$query_plant = "SELECT * FROM plant WHERE plant_enable=1 ORDER BY plant_name";
$rs_plant = DB_Query($query_plant);
while ($row_plant = DB_FetchRow($rs_plant)) {
$plant.='<option value='.$row_plant["plant_id"].'>' .$row_plant["plant_name"].' ['.$row_plant["plant_id"].']</option>';
}
mysql_free_result($rs_plant);
echo $plant;
?>
</select>
</span></div></td>
<script type="text/javascript">
$(function () {
$('#plant').multiselect({
includeSelectAllOption: true
});
$('#btnSelected').click(function () {
var selected = $("#plant option:selected");
var message = "";
selected.each(function () {
message += $(this).text() + " " + $(this).val() + "\n";
});
alert(message);
});
});
</script>
