0
Hello! I’m having problems I’m using in a form a multiple select field with the choseen-select plugin http://harvesthq.github.io/chosen/
<form id="cadastro" action="process_teste.php" method="post">
<select id="form-edit-selecionar" name="fornecedor[]" data-placeholder="Fabricantes" style="width:330px;" multiple class="chosen-select" tabindex="2">
<?php while($row2Fnc = mysqli_fetch_assoc($result2Fnc)) :?>
<option value="<?=$row2Fnc["id"];?>"><?=$row2Fnc["blablabla"];?></option>
<?php endwhile ?>
</select>
<button type="submit">Enviar</button>
and I’m getting data from php via ajax with $getJSON and want to add the id in the value of select, I tried it here but it didn’t work, the variable options_val has all ids, but select this null!
$.getJSON('process_forn.php?valor='+data, function (dados){
var options_val = [];
for (var i = 0; i < dados.length; i++) {
options_val += dados[i].id;
}
$("#form-edit-selecionar").val(options_val);
alert(options_val)
});