How to submit two forms on same page with one submit button?

  • msechrest
    Asked on April 24, 2014 at 7:31 PM

    Hello JotForm Support!

    I am working on a project that requires me to have 2 forms on the same page. I am trying to force one submit button to complete both forms but am not having any luck. I tried to use my own function but it keeps saying that it is Undefined.

    Here is the javascript I tried:

    function submitForms() {

     document.getElementById("formone").submit();

     document.getElementById("formtwo").submit();

    }

    I added those ID's to the form so they should be Defined. Is it possible to do this with Jotform? 

    Please let me know.

    Thank you,

    Matthew Sechrest

  • Jeanette JotForm Support
    Replied on April 24, 2014 at 11:17 PM

    I think you can make the "trick" using Page breakers (find this field under Survey Tools)

    You must create the "first form" before the page break , and the second form after that.

    How to submit two forms on same page with one submit button? Image 1 Screenshot 20

     

     

     

     

     

    Then, you can rename the "next" button if you will, and you can even hide the "Back" button on second page, by injecting this custom CSS code

    .form-pagebreak-back-container {

    display:none;

    }

    This way, you'll be able to submit 2 forms in a single submit button. The collapse tool (under Survey Tools) can be also another way.

    I hope this gives you better ideas on how to accompiish your scenario. Do not hesitate to contact us again.

  • msechrest
    Replied on April 25, 2014 at 4:14 PM

    Thank you for your response, It lead me in the right direction and I have it working now. 

     

    Thanks Again!

  • BrianPaulo
    Replied on April 25, 2014 at 4:27 PM

    You can try this code:

    function submitForms() {

     document.forms("formone").submit();

     document.forms("formtwo").submit();

    }

    Also, please don't forget to change the type of your button from "submit" to simply button. Call the function by using the onClick event.

    Bryan