I'm having a problem regarding my multiselect bootstrap plugin I'm getting my data from a query
try {
$sql = "SELECT Turma, idEscola FROM turmas WHERE (Estado = 1 AND idEscola =:val) ORDER BY Turma ASC;";
$query = $DB_con->prepare($sql);
$query->bindparam(":val", $visitaEscola);
$query->execute();
$result = $query->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
echo "<option value='{$row['idTurma']}'>{$row['Turma']}</option>
";
}
} catch (PDOException $e) {
echo $e->getMessage();
}
and this query is called by an ajax call
var turmasVisita = $(this).val();
$.ajax({
type: 'POST',
url: '/miga/db/getFromDatabase.php',
data: {get_option_escola_turma: turmasVisita},
dataType: 'html',
success: function (resposta) {
console.log(resposta);
document.getElementById("turmas").innerHTML = resposta;
$('#turmas').multiselect('rebuild');
}
});
The problem is when i check the console log i'm getting this
<option value="">1ºA</option>
<option value="">1ºB</option>
<option value="">2ºA</option>
So i have no option value
And using var_dump i have
{ ["Turma"]=> string(4) "1ºA" ["idEscola"]=> string(1) "1" } 1ºA array(2) { ["Turma"]=> string(4) "1ºB" ["idEscola"]=> string(1) "1" } 1ºB array(2) { ["Turma"]=> string(4) "2ºA" ["idEscola"]=> string(1) "1" } 2ºA array(2) { ["Turma"]=> string(4) "2ºB" ["idEscola"]=> string(1) "1" } 2ºB array(2) { ["Turma"]=> string(4) "3ºA" ["idEscola"]=> string(1) "1" } 3ºA array(2) { ["Turma"]=> string(4) "3ºB" ["idEscola"]=> string(1) "1" } 3ºB array(2) { ["Turma"]=> string(4) "3ºC" ["idEscola"]=> string(1) "1" } 3ºC array(2) { ["Turma"]=> string(4) "4ºA" ["idEscola"]=> string(1) "1" } 4ºA array(2) { ["Turma"]=> string(4) "4ºB" ["idEscola"]=> string(1) "1" }
So my question is why i'm not receiving the idTurma field after ajax call?
UPDATE
Html
<div class="form-group">
<label for="recipient-name" class="control-label">Turmas participantes</label>
<select name="turmas[]" id="turmas" class="form-control" multiple="multiple">
<option value=""></option>
</select>
</div>