All letters There are 2 forms and 2 submissions.

<form id="1"> <input id="1" name="alehsa-1" value="1"></input> <input id="1" name="alehsa-2" value="2"></input> </form> 

and

 <form id="2"> <input id="3" name="alehsa-3" value="3"></input> <input id="4" name="alehsa-4" value="4"></input> </form> 

When you click on submit a form 1, data is added from input 1 and 2, and when you click on submit a form 2, data 3 and 4 but you need to add more data from the first form from input id-1. How to turn it all for wood on the ears. Thanks in advance for the turnkey solution.

    2 answers 2

    Sending data with one type of submit from different forms is impossible. You can do this in other ways:

    Simple and cheap solution: Make it all one shape. And in the receiving script, use the values ​​that are required.

    Difficult and expensive solution: Make hidden fields in forms to which you will copy user input through JS.

      Quickly you can do it with javascript and jQuery:

      On the submit event of any of the forms, serialize them with jQuery.serialize and reload the page with the form parameters using the window.location JavaScript service object.

      Accordingly, if you need to go to another page, you need to enter the address before the question mark "?"

        <form id="f1" class="s-form"> <input id="i1" name="alehsa-1" value="1"> <input id="i2" name="alehsa-2" value="2"> <input type="submit"> </form> <form id="f2" class="s-form"> <input id="i3" name="alehsa-3" value="3"> <input id="i4" name="alehsa-4" value="4"> <input type="submit"> </form> <script src="http://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script> <script> jQuery('.s-form').submit(function () { window.location.search = "?" + jQuery(".s-form").serialize(); }); </script> 

      Remember that the "id" attribute must be unique on the page. This is what distinguishes it from the "class" attribute.

      • This type of variable of the two forms pulls into obshchak? - Vladislav_Carley
      • Yes, and sends to the page, passing these parameters as $ _GET. - user3127286