1
I created an Ajax request to fill in a field select when the user clicks on a certain specialty appear only the professionals qualified for the same. However, when clicking on another specialty the name of the other professionals prevail there. It would have to change this, for when the user select type reset what had there and put the new select.
<script>
function buscarMedicos(especialidades) {
$.ajax ({
url: 'select.php',
type: 'POST',
async: true,
dataType: 'json',
data:{'especialidades' : especialidades},
success: function (result)
{
if (result != "")
{
for (var i = 0; i < result.length; i++)
{
var aux = result[i];
var campoSelect = document.getElementById("umedico");
var option = document.createElement("option");
option.text = aux;
option.value = aux;
campoSelect.add(option);
}
}
}
})
}
</script>
var fieldSelect = Document.getElementById("umedic"); this is the select q that will receive the options?
– Wees Smith
@Weessmith Positivo.
– Gabriel
Declare that line before the for
var campoSelect = document.getElementById("umedico");
and right after clean her upcampoSelect.append('')
still before the is or before the if can be– adventistaam
didn’t work @adventistaam
– Gabriel
nor using the Select.html(') field. Try to set and clear the cache
– adventistaam