4
I am trying to make my select empty after the previous select is modified. (Since the two are interconnected, where the select1 is state and as the state is released the cities in Select2
HTML code where the person selects the state, after selected state returns the cities of the selected state, and has the search button to search for items present in the respective city.
<div class="row rol-inp">
<div class="row input-form">
<div id="slct-estado">
<span class="blt"></span>
<select id="selectEstado" name="estado" onchange="javascript: getCitiesFromState(this.value)">
<option value="">Estado </option>
<?php foreach ($estados as $est) { ?>
<option value="<?php echo $est->UF; ?>"> <?php echo $est->UF; ?> </option>
<?php } ?>
</select>
</div>
</div>
<div class="row input-form">
<div id="slct-estado">
<span class="blt"></span>
<select id="cidadesSelect" name="cidades">
<option value=""> Cidade </option>
</select>
</div>
</div>
<div class="row borda">
<a onclick="getStoresFromCity(this.value)" class="bt-concluir"><strong>Encontrar</strong></a>
</div>
</div>
Below, code that takes cities according to state, which already has value="", but is not working.
function getCitiesFromState(estado) {
document.querySelector('select[name=cities]').value="";
$.ajax({
url: ROOT + LANG + "/facebook/getCitiesFromState",
dataType: "html",
type: 'POST',
data: {
estado: estado
},
success: function (html) {
$("#cidadesSelect").html(html);
}
});
}
How so empty? You want to prevent the user to change the status after it is selected?
– Leandro Angelo
Do you think your problem has to do with PHP or Java? Why are you using these tags?
– Sam