Multiple Instances with one Thank You Message | Community
Skip to main content
New Participant
February 15, 2023
Solved

Multiple Instances with one Thank You Message

  • February 15, 2023
  • 1 reply
  • 1741 views

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.
Best answer by SanfordWhiteman

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;
  });
});

 

 

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
February 16, 2023

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;
  });
});

 

 

dbarbaAuthor
New Participant
February 16, 2023

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>

SanfordWhiteman
New Participant
February 16, 2023

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.