2
I have two almost equal forms, one for individuals and one for legal entities and these forms are hidden and appear as the result of a jQuery().change determining whether the form is for a natural person or a legal person to be used.
On both forms I’m calling ids identical where in the pfisica has #estado and #cidade and in the pjuridica also, I need the same information.
A function jQuery(). change in select #estado calls the function buscar_cidades() which captures the id of the selected state and searches the database with Ajax.
How the 2 Forms load on the same page and appear as you choose between PF or PJ, how I will solve this problem of ids knowing that duplicated ids conflict with jQuery?
A solution would be to create two pages but I didn’t want to do that. Another solution would be to change the ids and duplicate the function search_cities and change the name of the function that would call the ids of the other form but I think this more POG what else.
How to solve?
Instead of identifying by Id, assign a common class (same name) to both components, and select by class name instead of selecting by Id.
– Caffé
^^^^this, the problem of Ids is solved with classes. [ps] if you publish a summary of your code here gives a more complete answer.
– brasofilo
Thank you guys, as I finished the question, I thought
class. I’m gonna test.– Marcos Vinicius