Reputation: 621
I have a problem selecting the selected value to show in the multiple select inputs.
Now my problem is, I am doing an update function, so the data will show in input first, like below the picture, the value (developer1, developer2, developer) are missing:
But if I continue to select another value in the multiple select function input, it cannot show previously selected value in the multiple select function input, just can show newly selected value only like the below picture:
This is my mulit-select function coding:
<div class="col-lg-6">
<div class="form-group">
<label>Ahli-ahl
<select id="<?php echo $span_mandatory; ?></label><br>hli_ahli" name="ahli_ahli" class="form-control <?php echo $class_mandatory; ?>" title="Ahli-ahli" multiple>
<?php
$sql_user = 'SELECT * FROM user where is_active=1';
$row_user = base_mysqli_select($sql_connection, $sql_user, $types, $values);
foreach ($row_user as $val_user) {
echo '<option value="' . $val_user['id'] . '">' . $val_user['name'] . '</option>';
}
?>
</select>
</div>
</div>
<script>
$(document).ready(function(){
$('#ahli_ahli').multiselect({
nonSelectedText: 'Pilih ahli-ahli',
enableFiltering: true,
enableCaseInsensitiveFiltering: true,
buttonWidth:'100%'
});
});
</script>
This gets the selected value in the multi-select bootstrap coding:
function call_to_set_Selected(ahli_ahli) {
for (var i = 0; i < ahli_ahli.length; i++) {
//add option selected
$('option[value="' + ahli_ahli[i] + '"]', $('#ahli_ahli')).prop('selected', true);
}
//refresh mutlislect
$('#ahli_ahli').multiselect('refresh');
}
Is multi-select function bug or my code is wrong to define? Hope someone can guide me on how to solve this problem. Thanks.
Upvotes: 0
Views: 317