I want to change the content of several select neighborhoods depending on the municipality chosen in another select.
This is how I do it with a single select neighborhood
<script type="text/javascript">
function CargarBarrios(idSelBarrio, idMunicipio){
$.ajax({
type: "GET",
url: '/geo_location/barrio/consultar_barrios_por_municipio/'+idMunicipio,
traditional: true,
data: {
},
dataType: 'json',
success: function(data){
var options = '<option value="">-Seleccione-</option>';
for (var i = 0; i < data.length; i++) {
options += '<option value="' + data[i][0] + '">' + data[i][1] + '</option>';
}
$("#"+idSelBarrio).html(options);
}
});
}
</script>
But now I need to do it with more than one select neighborhood, they will all contain the same information.
I appreciate the help you can give me
If the information is the same in all the selects then you can use a class selector instead of an id selector.
And to all the select you put the same class, for example: