0
I’m new to development and I need help. I have a select in html that I need updated when selected from another select.
Follows html code:
$(document).ready(function () {
$('select[name=camporegiao]').on('change', function () {
$.ajax({
type: 'GET',
url: '../../FiltroFilial',
data: 'idregiao=' + $('select[name=camporegiao]').val(),
statusCode: {
404: function () {
alert('Pagina não encontrada');
},
500: function () {
alert('erro no servidor')
}
},
success: function (dados) {
$('select[name=campofilial]').refresh????;
}
}
});
})
});
<div class="col-md-3">
<p>
<b id="reg" name="reg">Região</b>
</p>
<select id="camporegiao" name="camporegiao" class="form-control show-tick" data-live-search="true">
<% for(Regiao regiao: fdao.listarRegiao()){ %>
<option value=<%=regiao.getId()%>><%=regiao.getRegiao()%></option>
<% } %>
</select>
</div>
</div>
<div class="row clearfix">
<div class="col-md-3">
<p>
<b>Filial</b>
</p>
<select id="campofilial" name="campofilial" class="form-control show-tick" data-live-search="true">
<% for(Filial filial: fdao.listarFilial()){ %>
<option value=<%=filial.getId()%>><%=filial.getFilial()%></option>
<% } %>
</select>
</div>
I don’t know how to do in javascript Thank you in advance
Maybe
$('select[name=campofilial]').html(dados)
?– bfavaretto
To be accurate in the solution we would need to see how is the return of your ajax, ie what content returned in data. But as stated above the path would be using . html() or similiar.
– Caique Romero
Hello It didn’t work I got this to refresh the full page window.location.Reload() But I would like to refresh the select $('select[name=campofilial]').location.Reload();
– Antonio Neto