2
How do I know which form id is sent from which function? The function is buscar_cidades()
and is present in 2 forms Pessoa Física
and Pessoa Jurídica
.
How to know in jQuery which form(id) is being sent the function?
<form action="" id="pessoa_fisica">
<select name="estado" onchange="buscar_cidades()">
...
</select>
</form>
<form action="" id="pessoa_juridica">
<select name="estado" onchange="buscar_cidades()">
...
</select>
</form>
Updating
Knowing which id is sending the function, how to capture the select of that id knowing that select has class estado
?
var formid = $(e).closest("form").attr("id");
var estado = ??????????
You helped me perfectly, you can just give me one more push on the part Updating of the question??
– Marcos Vinicius
The
select
is the$(e)
jQuery when inside the function. If for example you want the selected value:alert($(e).find('option:selected').val());
– Zuul