I have serveral forms(user can add new form dynamically) in one page, they're all submitted to the same struts2 action. I need to submit all these forms when the user clicks the save button.
Things go well in FF. But in IE and Google chrome, only the last form is submitted.
Any help is appreciated. Thank you.
Each form's elements are the same, one form one object. Every form's data will be added to an domain object then the object will be persisted to DB.
Javascript function to handle save operation:
<script type="text/javascript" >
function submit() {
var formCnt = document.getElementById('formCnt').value;
for(var i = 1; i <= formCnt; i++) {
var formName = 'form' + i;
document.forms[formName].submit();
}
}
</script>
...
<input type="hidden" id="formCnt" name="formCnt" value="5" />
<form action="add.htm" name="form1" id="form1" method="post" enctype="multipart/form-data" />
<input type="text" name="item.price" id="item.price" value="" />
...
</form>
<form action="add.htm" name="form2" id="form2" method="post" enctype="multipart/form-data" />
<input type="text" name="item.price" id="item.price" value="" />
...
</form>
...
<form action="add.htm" name="form5" id="form5" method="post" enctype="multipart/form-data" />
<input type="text" name="item.price" id="item.price" value="" />
...
</form>
...