0
Simply put, I have a select (combobox) in my html and would like to know which Input (position) has been chosen. that is, if it was the first, the second, the third... The reason is that in my ajax I receive an array of products, and the "price" field will receive the value depending on the selected select. HTML:
<select class="form-control" id="selectProdutos">
<option selected>Escolha uma opção</option>
</select>
Javascript:
for (var i = 0; i < data.length; i++) {
$('#selectProdutos').append('<option>' + data[i].descricao + '</option>');
}
You should include a property
value
in its elements<option>
, then just get thevalue
of<select>
, which will have the same value as<option>
selected.– Andre
You saved my night, thank you very much. I don’t know how to enjoy or accept your answer
– Weesed