My page design is such that I have to use two forms that submit on single click and then saved to database and vice verse. I am using this on a JSP page with Struts2 Framewo
You can use jQuery .serialize to do what you want. Give some class to your forms then use it to select your forms and call serialize to get a string in the standard URL-encoded notation. After that you can use some AJAX method to post it to your action.
$(function() {
$("#saveNoteButton").click(function() {
alert($(".forms").serialize());
});
});
Found an easy solution to it.
javascript:
submitForms = function() {
$('#form2 :input').not(':submit').clone().hide().appendTo('#form1');
document.getElementById("form1").submit();
};
Submit button :
<input type="button" value="Save Note" onclick="submitForms()" />
You can use Struts2 jQuery to submit multiple forms
<sj:submit formIds="visitType,patientCondition" targets="result" value="Submit" />
formIds:
Comma delimited list of form ids for which to serialize all fields during submission when this element is clicked (if multiple forms have overlapping element names, it is indeterminate which will be used)