Repost of CUSTOM MODULE / INPUT FORM: Can I submit 2 forms on 1 page with 1 submit button?

@on.works I’d love to hear how you can do this. Thanks :slight_smile:

Is it possible to submit 2 forms on 1 page with 1 submit button?
How does error handling work?
Could one get submitted and not the other?
Is this against “best practice”?

@shannonlynd I’m unsure why you are wanting to do this but maybe you could approach it in a different way: At the end of the first form, have a submit button that says ‘continue’ that submits the first form and takes the person to the second form made out to look like Part 2 of the same form. You can carry over information submitted in the first form (such as name & email address) into hidden fields in the second form.

@shannonlynd Yes this can be done. I’m not sure it would qualify as ‘best practice’. (Best hack perhaps. Also ‘best result’ if it’s the only solution in the toolbox).

@hopestew we’ve use this method from time to time to copy values to a hidden form that posts to Jotform.com. Jotform is highly flexible. Case in point… We have a BC client that sends three emails to webinar & seminar subscribers. 1= Autoresponder. 2= Reminder 24hrs before event. 3= Follow-up 24hrs after event. This is achievable in BC. But can only do autoresponder in Treepl.

So we hide a form (jotform) on the page, populated with the event name and date, plus the values from 4 custom properties added to the the events module (i.e. 2 x message contents + the dates to send them). Finally we copy the customers name and email address when the values are entered on the main form.

e.g.
Form (visible):

< form id=“visible_form” action="treepl action url … etc …>
< input name=“Email” onBlur=“document.getElementById(‘jotfield_3’).value=this.value;” … >
< input type=“button” id=“submitButton” … etc … >

Jotform (hidden):

< form id=“hidden_jotform” action=“jotform action url … etc … >
< input name=“Email” id=“jotfield_3” value=” " … etc… >
< textarea id=“jotfield_9” name=“reminder-email” data-richtext=“Yes” … etc … >
{{this[‘ReminderEmailContent’]}} < /textarea >

Script:
$(document).ready(function () {
$(“#submitButton”).click(function () {
$.post($(“#visible_form”).attr(“action”), $(“#visible_form”).serialize(),
function () {
alert(‘Form 1 submitted’);
});
$.post($(“#hidden_jotform”).attr(“action”), $(“#visible_form”).serialize(),
function () {
alert(‘Form 2 submitted’);
});
});
});

Posting form values into Jotform allows significant capability including sharing the data to Zapier so anything becomes possible. This has been a DIY-API solution for us numerous times.

I can share a live example with you in a few days time if you like? (in development).
Cheers…
Andy

Thanks. I can definitely see your use case. I found a better way, but will save your code just in case.

:slight_smile: Shannon

I’ve created a forum post to flesh out our request for Zapier integration. Please feel free to add your ideas over there if they haven’t been covered Zapier Integration