0

I have input sets with same names, and i need to submit thems to same action. When i try to submit that forms, only one form is posted.

Like this:

<form id="form1"  name="form1" action="aaa.php" method="post">
<input type="hidden" name="id_product" value="2"/>
<input type="hidden" name="add" value="1" /> </form>

<form id="form2"  name="form2" action="aaa.php" method="post">
<input type="hidden" name="id_product" value="3"/>
<input type="hidden" name="add" value="1" /> </form>
  • 4
    So whats wrong..You have created two different forms.For each form different submit event will get executed.I dont see any valid requirement submitting two forms on submit action.Plz elaborate.Y dont you put everything under single form and then submit whole form? – Deepak Ingole Aug 23 '13 at 02:51
  • I think there is some ambiguity here. Shouldn't the name of the two forms should be the same and name of the two inputs - different (unless they are radio buttons for example)? – ılǝ Aug 23 '13 at 03:07

1 Answers1

0

That's because you can submit only one form at a time. Besides, your fields have the exact same name so it doesn't make much sense to submit both.

You could clone the fields of your second form into the first form using JavaScript, though it wouldn't work if the user has JavaScript disabled in his browser. That or wrapping all your fields into one form, calling the first two fields id_product_1 and add_1 and the second two id_product_2 and add_2 respectively, for example.

But in all, it sounds like you have a design problem.

Community
  • 1
  • 1
federico-t
  • 12,014
  • 19
  • 67
  • 111