Organizing values of child elements for processing of a sortable form

Organizing values of child elements for processing of a sortable form

in my form, the user can click a button to create input fields. Inside each of the created input fields, they can click the "add media links" button to create another input field underneath. They can add as many media links as they please or none at all. The first set of input fields are also sortable. I have the user interface working, I'm just wondering how to go about processing it.

right now, I am basically grabbing all of the values entered from the first set of input fields (aka "thestepvalues" in the code) and then grabbing all of the values entered from the second set of input values (aka "links" in the code) and then URL enconding it and serializing it to send to the my process.php file. 

For a sample of data entered into the form, how do I go about indicating which link belongs to the parent input field? Baring in mind the parent input fields are sortable jquery ui elements.

Any help would be greatly appreciated, thanks in advance

-- 24x7

The code is below:

$("#new_post").submit(function(e){ e.preventDefault(); //enter each of the values for 'the step' input field into an array var thestepvalues = $("input[name='thestep\\[\\]']") .map(function(){return $(this).val();}).get(); //enter each of the values for each 'links' input field into an array  var linkvalues = $("input[name='link\\[\\]']") .map(function(){return $(this).val();}).get(); //this will basically convert everything entered into the steps as well as the links fields //into URL appropriate strings to pass on to the process.php file var i, string=""; for(i=0;i<thestepvalues.length; i++){ string += "thesteps[]=" + encodeURI(thestepvalues[i]) + "&"; } for(i=0;i<linkvalues.length; i++){ string += "links[]=" + encodeURI(linkvalues[i]) + "&"; } //send the data from the string (both kinds of input fields) as well as any //other input fields (that aren't dynamic) from the form $.post("process.php", string + $("#new_post").serialize(), function(data){ if(data.email_check == 'invalid'){ $("#message_post").html("<div class='errorMessage'>Sorry " + data.name + ", " + data.email + " is NOT a valid e-mail address. Try again.</div>"); } else { $("#message_post").html("<div class='successMessage'>" + data.email + " is a valid e-mail address. Thank you, " + data.name + ".</div>"); } }, "json"); });