I am using bootstrap to create select multiple function. Now my problem is I want to follow my selected value to show in the select multiple function, but it cannot work. Below is my problem coding:
<select id="jabatan_edit" name="jabatan_edit" title="Jabatan" class="form-control">
<?php
$sql_jabatan = 'SELECT * FROM jabatan where is_active=?';
$types[] = 'i';
$values[] = 1;
$row_jabatan = base_mysqli_select($sql_connection, $sql_jabatan, $types, $values);
foreach ($row_jabatan as $val_jabatan) {
$jabatan = "1,3";
$check_jabatan = $val_jabatan['id'];
$jabatan_value = explode(',',$jabatan);
if (in_array($check_jabatan, $jabatan_value ))
{
$selected_jabatan = 'selected="true"';
}
else
{
$selected_jabatan = 'selected="false"';
}
echo '<option value="' . $val_jabatan['id'] . '" ' . $selected_jabatan . '>' . $val_jabatan['kod_jabatan'] . '</option>';
}
unset($types);
unset($values);
?>
</select>
This is my javascript function:
$('#jabatan_edit').multiselect({
nonSelectedText: 'Pilih ahli-ahli',
enableFiltering: true,
enableCaseInsensitiveFiltering: true,
buttonWidth:'100%'
});
My output is shown me like below the picture, the result just can show $jabatan value = 3:
May I know how to display the selected values correctly? For example I want the actual result like below can show $jabatan value = 1,3:
Hope someone can guide me on how to solve this problem. Thanks.