3
Hello, Community!
I have two selects in HTML one with the regions of Brazil and the other with the states. How do I fit them without using a template (PHP, Java, C# etc), only with HTML (the selects) and jQuery?
//select regiao/estado encadeados/dependentes
$('#regiao').on('change', function(){
var regiao = $(this).val(), estado = $('#uf');
// filtrar os estados de acordo com a regiao selecionada
});
<!-- select com as regiões do Brasil -->
<select id="regiao" name="regiao">
<option value="CO">Centro-oeste</option>
<option value="NE">Nordeste</option>
<option value="N">Norte</option>
<option value="SE">Sudeste</option>
<option value="S">Sul</option>
</select>
<!-- select com os estados do Brasil -->
<select id="uf" name="uf">
<option value="AC" class="N">Acre</option>
<option value="AL" class="NE">Alagoas</option>
<option value="AP" class="N">Amapá</option>
<option value="AM" class="N">Amazonas</option>
<option value="BA" class="NE">Bahia</option>
<option value="CE" class="NE">Ceará</option>
<option value="DF" class="CO">Distrito Federal</option>
<option value="ES" class="SE">Espírito Santo</option>
<option value="GO" class="CO">Goiás</option>
<option value="MA" class="NE">Maranhão</option>
<option value="MS" class="CO">Mato Grosso do Sul</option>
<option value="MT" class="CO">Mato Grosso</option>
<option value="MG" class="SE">Minas Gerais</option>
<option value="PA" class="N">Pará</option>
<option value="PB" class="NE">Paraíba</option>
<option value="PR" class="S">Paraná</option>
<option value="PE" class="NE">Pernambuco</option>
<option value="PI" class="NE">Piauí</option>
<option value="RJ" class="SE">Rio de Janeiro</option>
<option value="RN" class="NE">Rio Grande do Norte</option>
<option value="RS" class="S">Rio Grande do Sul</option>
<option value="RO" class="N">Rondônia</option>
<option value="RR" class="N">Roraima</option>
<option value="SC" class="S">Santa Catarina</option>
<option value="SP" class="SE">São Paulo</option>
<option value="SE" class="NE">Sergipe</option>
<option value="TO" class="N">Tocantins</option>
</select>
Guys, how do I use the "Execute Code Snippet" function when asking?
– Marcos Vinicius