I've got a form that dynamically generates sets of input elements. First there is a set of up to 99 parent elements, and then the parents can have up to 99 child elements each. My question is not about the generation, but about capturing the data once the form has been filled out.
I made a script that handles getting the values and putting the values, along with their input id in an object that is used later. I don't want to have to use css classes or other attributes to identify the input elements, and wondering if that being the case, if I could get a critique of my script:
The output (the object) logs to your console when you click anywhere in the Result area.
What do you mean by 'capturing'? If it is to post back to the server you can just use the jQuery .serialize() function to get all the form elements and their values into a post body.
I can see in your example that you are combining the ids into an object, but perhaps you want it structured?
Yes, I know I could use serialize, but by capturing I just meant that I want to put all of the values from the fields in an object. The form is very large, and parts of it show and parts are hidden, making it seem as though there are pages. $.serialize would work if I want to GET or POST the entire form, but only one part is done at a time. You are probably wondering why I haven't just made separate forms for each page... and I think I am wondering the same thing right now.