Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 361517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:53:43+00:00 2026-05-12T12:53:43+00:00

I have several forms(user can add new form dynamically) in one page, they’re all

  • 0

I have several 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>

   ...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T12:53:46+00:00Added an answer on May 12, 2026 at 12:53 pm

    You should only be able to submit one form at a time. A submit button must be inside <form> tags, and only the form that the submit button is in should be submitted. That hidden input tag there should be inside a form tag as well BTW.

    Even when doing it via JS, a submit() initiates a new POST request to the server. You can only make one request at a time, that’s why only the last shows up. I have no idea why it would work in FF.

    If you need to submit everything at once anyway, why break it up to begin with? If you want “subsections” in a form, you can use the <fieldset> tags.

    Edit

    What happens when you run your script is the same as if all your forms have a submit button, and you click all submits buttons in rapid order. Clicking one submit button sends the data of that form to the server in a POST request and refreshes the page. If you’re fast enough to click another button before the page refreshes, you can submit another form, the old request will be canceled.

    The only way I can imagine how the data of all forms could possibly get to the server the way you’re doing it is if the request happens to be send before the next submit() is triggered. Essentially you’re relying on the browser being slow, or at least handling the request before continuing the script execution. Apparently that works in FF, but fails in other browsers. As it should.

    Edit 2

    If you need to submit multiple fields with the same name, use one form and give your fields unique names. The best naming scheme depends on how your backend handles form submissions.

    • item0, item1
    • item.0, item.1
    • Model.0.item, Model.1.item
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several forms on one page which are submitted using ajaxForm and show
I have an app that lets the user interact with several forms. I can
I have a page that contains several forms, by submitting each one of them,
I have a page that has several ajax submission forms. Each form has a
I have a user control on a form that can spawn several non-modal child
I have several forms added to the pages of the tab control via tabcontrol.tabpages.controls.add
I have a website with several forms that all pass the same set of
I want to have a feature to submit several forms on a page when
I have an admin page for a store where a user can modify item
I have a form with a select list, where the user can select anywhere

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.