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?
One approach is to copy all of form2's inputs into form1 once the data validation check succeeds. This assumes you are not doing an AJAX submit.
// new onsubmit function for form1
function form1_onsubmit()
{
if (!EntryCheck()) return false;
$('#form2 :input').not(':submit').clone().hide().appendTo('#form1');
return true;
}
If you wanted to cater for hitting submit twice, possibly because of submit fail from the server, we would need to remove any copied inputs before copying in new ones.
// new onsubmit function for form1
function form1_onsubmit()
{
$('#form1 :input[isacopy]').remove();
if (!EntryCheck()) return false;
$('#form2 :input').not(':submit').clone().hide().attr('isacopy','y').appendTo('#form1');
return true;
}