SOLVED

Insert text after hiding embedded form on submit

Go to solution
Anonymous
Not applicable

Insert text after hiding embedded form on submit

I would like to use an embedded form to capture subscribers to my blog.  When I embed the form, I plan to use the developer code to hide the form upon successful submission.

What I'd like to do is add some text to appear in place of the form - e.g. "Thank you for subscribing".  Does anyone know how I can do that?

The code to hide the embedded form is as follows:

<script>MktoForms2.loadForm("//my.marketoinstance.com", "my account", form number,  function(form){
  //Add an onSuccess handler
  form.onSuccess(function(values, followUpUrl){
    //get the form's jQuery element and hide it
    form.getFormElem().hide();
    //return false to prevent the submission handler from taking the lead to the follow up url.
    return false; 
      });
});</script>


Thanks in advance for your help!
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: Insert text after hiding embedded form on submit

What you can do is to have a the message you want after submiting the form to be in a hidden div right after your form. 

Let's say your message is in:

<div id="msg" style="display:none;"> Thank you for subscribing </div>

Then in your code right after   form.getFormElem().hide();

$('#msg').show();


 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Re: Insert text after hiding embedded form on submit

What you can do is to have a the message you want after submiting the form to be in a hidden div right after your form. 

Let's say your message is in:

<div id="msg" style="display:none;"> Thank you for subscribing </div>

Then in your code right after   form.getFormElem().hide();

$('#msg').show();


 
Anonymous
Not applicable

Re: Insert text after hiding embedded form on submit

Thanks!  That worked great!
 
Anonymous
Not applicable

Re: Insert text after hiding embedded form on submit

Hi, I would like to so a similar thing but the code provided is not working for me. Maybe I am writing it wrong? Any feedback would be highly appreciated.

<script src="//app-ab06.marketo.com/js/forms2/js/forms2.min.js"></script>

<form id="mktoForm_1133"></form>

<div id="msg" style="display:none;"> Thank you</div>

<script>MktoForms2.loadForm("//app-ab06.marketo.com", "790-LFQ-371", 1133,function(form) {

       // Add an onSuccess handler

    // Add an onSuccess handler

    form.onSuccess(function(values, followUpUrl) {

        // Get the form's jQuery element and hide it

       

     form.getFormElem().hide();

    

$('#msg').show();

return false;

});

});

</script>

SanfordWhiteman
Level 10 - Community Moderator

Re: Insert text after hiding embedded form on submit

There are many recipes to accomplish this kind of thing -- search old Comm'ty posts for my demos.

Here's one: MktoForms2 :: Replace Form with TY Text