0
Good afternoon, I’m trying to make the action change of jquery work inside a modal that is inside a while loop in php, where I use a select from the STATES field that popular another select from the CITIES field, when I called the first record of my query it works normal and searches the cities according to the state I selected, this is when I do the record editing process, follow the script:
//FUNCAO PEGAR CIDADES NATURALIDADE $(function (){ $("#ufs").change(function(){//aqui a função é ativa qdo o usuário sair do campo cpf var estados = $("#ufs").val(); $.post("includeAjax/carregar-cidades.php", {id:estados}, function(pegar){ $("#cidades").html(pegar); }); }); });
More when I edit the second record and open the modal, and I will trigger the select , it just doesn’t perform change action by selecting the States field, does anyone know how to force the jquery change on that action? I hope I explained it well!
You can make one
.each
in the options of #ufs and dai for each val() to perform the function– Vinicius Shiguemori
Can you elaborate on that? " while loop in php" I think this is creating ID conflicts in the gift so it doesn’t run the second change, it created the click event just for the first id. you can use a class instead of using a conflict-free id and to get the value of the state use $(this). val()
– arllondias