I have two forms on one html page. Using jQuery, is it possible to have the data from both forms go into the POST data when the first is submitted?
This is a clean JavaScript approach for merging two forms. I test it with a POST request with Prototype and jQuery and it works. This is the thing:
var data1 = document.getElementById('form1').serialize();
NOTE: form1 is form's id .You need to set it within
var data2 = document.getElementById('form2').serialize();
NOTE: form2 is form's id. You need to set it within
Now you have two vars and two serialized data (arrays). You can easily merge them. Your form will have assoc. array and you can get a problem when you try using concat function.
var mergeddata = data1 + '&' + data2;
This is it! You can easily send them through ajax call. For example, Prototype.js:
new Ajax.Request(url, {
method: 'post',
parameters: mergeddata, ...