"menu de cascata"
Bootstrap 4.1.1 Snippet by raquel2020

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- BEGIN SCRIPTS --> <script type="text/javascript" src="http://www.graciomar.com.br/js/jquery.min.js"></script> <title>Exemplo Combo dependente com Jquery</title> </head> <body> <h1>Exemplo Combo dependente com Jquery</h1> Estado: <select id="select_estado"> <option value="">Selecione o Estado</option> <option value="BA">Bahia</option> <option value="PE">Pernambuco</option> <option value="RJ">Rio de Janeiro</option> <option value="SE">Sergipe</option> </select> Município: <select id="select_municipio"> <option></option> </select> </body> </html>
$(document).ready(function(){ $('#select_estado').change(function(){ $('#select_municipio').html("<option value='' >Carregando...</option>"); var html_municipio = "<option value='' ></option>"; $.getJSON( 'http://www.graciomar.com.br/json_municipios.php?estado=' + $(this).val(), function(resposta ) { if(resposta[0].status == 'OK'){ for (var i = 1; i < resposta.length; i++) { html_municipio += '<option value="'+resposta[i].Codigo+'">' + resposta[i].Nome+ '</option>'; } }else{ $('#select_municipio').html("<option value='' ></option>"); } $('#select_municipio').html(html_municipio); }); }); });

Related: See More


Questions / Comments: