I have a form, which contains multiple virtual fieldsets.
Eg, MyForm:
Name1
Age1
Location1
Name2
Age2
Location2
Name3
Age3
Location3
Submit
If I allow the user to dynamically create more field sets on the client how can I loop through all fieldsets where name(x) is set and perform an similar action for each group, using the integer (1,2,3 etc) as a unique identifier?
I want to specify the actions once, loop through and each time change the variables used according to the number of the fieldset.
Right now, I am doing it manually for 3 hardcoded fireldsets, but it won’t scale:
Pseudocode:
if($name1 is set) {
do something using $age1 and $location1
}
if($name2 is set) {
do something using $age2 and $location2
}
if($name3 is set) {
do something using $age3 and $location3
}
Thanks!
Do it like this:
Hope this helps. Cheers