I'm new to development and need help. I have a select in html that needs to be updated when selected data from another select.
Follow 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 do not know how to do it in javascript Thanks in advance