Join 3 forms in 1 Submit

Asked

Viewed 914 times

1

Have 3 forms : Form1, form2 and form3.

I don’t know how I can " join them together " so you only need one <input type=submit /> for the three instead of creating a Submit for each one

  • Is there any way to do this?

  • If yes, where can I find documentations?

  • There are several formats that will send the data to the same place?

  • 1

    You can only give ONE Ubmit, if what you want is to send the data of these 3 Forms in the same Ubmit, then you need to better formulate your question, starting by posting the 3 Forms here so that it is possible to formulate the ideal answer.

  • Definitely you do not need to assemble three separate forms, if you use a little Javascript just recover the fields and get the respective values from them, then just send javascript to the server. Provide some of your code.

1 answer

3


Assuming you want to send all data in the same Ubmit and that you use jQuery, I will propose the following solution:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<form id="form-1">
    //seus campos aqui
</form>
<form id="form-2">
    //seus campos aqui
</form>
<form id="form-3">
    //seus campos aqui
</form>
<input type="submit" id="submit-forms"/>
<script>
$(function(){
    $('#submit-forms').click(function(){
        window.location.href = "urldesubmit.com.br?" + $('#form-1').serialize() + '&' + $('#form-2').serialize() + '&' + $('#form-3').serialize();
    });
});
<script>

It’s a hell of a gambit, but it should work.

  • Your code didn’t work here

  • Did you fire any errors? Do you have any other details?

  • Post on the question like you did...

  • Simply the Submit didn’t work just got a button without sending...

  • Tried to put an Alert in the event to see if it’s getting into it?

  • Won’t go either! :/

  • can post your code on the question, with Forms and jQuery?

  • I just tried to execute this code of yours and it wasn’t...

  • Did you add jQuery to the test page? to see the errors you have to open the browser console...if you do not post the code or inform which error is occurring I have no way to point out the solution, otherwise the Forms have to have their fields to send all the data correctly

  • Uncaught Referenceerror: $ is not defined -> Identical code to your answers with 1 field only <input type="text" name="teste" />

  • 1

    You have to add jQuery on the page, I edited the answer

  • *perfect It worked, thank you :D

Show 7 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.