Skip to main content
Level 2
Feb 15, 2023 10:40 PM UTC
Solved

Multiple Instances with one Thank You Message

How can we apply an overlay thank you message on 6 form instances?

<form class="mktoForm" data-formId="123" data-formInstance="one"></form> <form class="mktoForm" data-formId="123" data-formInstance="two"></form> <form class="mktoForm" data-formId="456" data-formInstance="one"></form> <form class="mktoForm" data-formId="456" data-formInstance="two"></form> <form class="mktoForm" data-formId="768" data-formInstance="one"></form> <form class="mktoForm" data-formId="768" data-formInstance="two"></form>

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Feb 16, 2023 2:49 AM UTC

From the looks of your markup, you’re trying to use my MktoForms2 :: Multiple Forms, Multiple Times code. (Note no one else would’ve recognized that, so best to be explicit!)

 

If you want only one thank you message (as in a single <div> that you unhide) you don’t need to do anything special, just don’t filter by form ID:

MktoForms2.whenReady(function(mktoForm){
  mktoForm.onSuccess(function(submittedValues,thankYouURL){
    // whatever you do applies to all forms
    return false;
  });
});

 

 

3 replies

SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Feb 16, 2023 2:49 AM UTC

From the looks of your markup, you’re trying to use my MktoForms2 :: Multiple Forms, Multiple Times code. (Note no one else would’ve recognized that, so best to be explicit!)

 

If you want only one thank you message (as in a single <div> that you unhide) you don’t need to do anything special, just don’t filter by form ID:

MktoForms2.whenReady(function(mktoForm){
  mktoForm.onSuccess(function(submittedValues,thankYouURL){
    // whatever you do applies to all forms
    return false;
  });
});

 

 

Translate
dbarbaAuthor
Level 2
Feb 16, 2023 5:52 PM UTC

Hello @sanfordwhiteman 

once I fill out the 6072 form then all forms thank you message appearing same time.

 

<script> MktoForms2.whenReady(function (form){ var samePageTYForms = [6072,6118,6120]; if ( samePageTYForms.indexOf(form.getId()) != -1 ) { form.onSuccess(function(values, followUpUrl){ document.getElementById('confirm-researcher').style.visibility = 'visible'; //return false to prevent the submission handler from taking the lead to the follow up url. var formElement = form.getFormElem()[0]; // .reset() is a native javascript method. formElement.reset(); return false; }); } }); </script>

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Feb 16, 2023 11:07 PM UTC

You’ll have to provide a link to your page. What you’re describing doesn’t make sense: onSuccess only fires for the form that successfully submitted, not all forms.

 

Also, what do you mean by “all forms thank you message”? In this code snippet, you appear to have one form-specific confirmation block (selected by id). I assume you have other code you aren’t showing, which makes troubleshooting close to impossible.

Translate