SOLVED

Re: Multiple Instances with one Thank You Message

Go to solution
debbie_917
Level 2

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>

 

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Multiple Instances with one Thank You Message

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

 

 

View solution in original post

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: Multiple Instances with one Thank You Message

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

 

 

debbie_917
Level 2

Re: Multiple Instances with one Thank You Message

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
Level 10 - Community Moderator

Re: Multiple Instances with one Thank You Message

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.