Hiding form after fillout on RTP popup - Murtza?

Dory_Viscoglio
Level 10

Hiding form after fillout on RTP popup - Murtza?

I'm sure that more people than just Murtza could answer this, but I've been going through the developers documentation to hide a form after successful submission, and either I'm adding the code to the wrong location, or it isn't working with the updated asynchronous code that support recommended for adding a forms 2.0 form to an RTP popup. 

The code recommended by support was:

<form id="mktoForm_1589"></form>
<script type="text/javascript">// <![CDATA[
$.ajax({ 
cache: true, 
async: true, 
url: "//app-sj05.marketo.com/js/forms2/js/forms2.js", 
dataType: "script", 
success: function(){ 
MktoForms2.loadForm("//app-sj05.marketo.com", "867-SLG-901", 1589); 

});
// ]]></script>

The code to hide the form upon submission is: 
 
  1. MktoForms2.loadForm("//app-sjst.marketo.com", "785-UHP-775", 1057, function(form){
  2. //Add an onSuccess handler
  3. form.onSuccess(function(values, followUpUrl){
  4. //get the form's jQuery element and hide it
  5. form.getFormElem().hide();
  6. //return false to prevent the submission handler from taking the lead to the follow up url.
  7. return false;
  8. });
  9. });
Can anyone point me in the right direction of putting hose two together so that they hide the form upon submission? Thank you so much in advance!
Tags (1)
4 REPLIES 4
John_Wallace
Level 4

Re: Hiding form after fillout on RTP popup - Murtza?

I believe that example they give will work.  In the form you just need inidcate what you want to happen after the form is submitted.  this  works for me,  I think forms 2.0 has ajax functionality built in.

<script src="//app-sjp.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_537"></form>
<script>MktoForms2.loadForm("//app-sjp.marketo.com", "466-AGZ-592", 537, function(form){

    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>
Dory_Viscoglio
Level 10

Re: Hiding form after fillout on RTP popup - Murtza?

Hey John, is this working for you on RTP? Support provided the code that I showed above because otherwise we were unable to get a the popup to show up on our page. When I use your code above in RTP (modified with our info), I'm having the same issue where I don't even get a popup. It would be great if Murtza or one of the other developers from Marketo could provide some guidance here since RTP seems to be a different beast!
Kenny_Elkington
Marketo Employee

Re: Hiding form after fillout on RTP popup - Murtza?

Hey Dory,

Can you provide a description of what exactly the issue is that you're seeing?  Is the Form not loading, or not hiding?
Dory_Viscoglio
Level 10

Re: Hiding form after fillout on RTP popup - Murtza?

Hey Kenny, thanks for the reply! When I preview with anything other than what's below, the popup doesn't appear at all. I also tried launching and RTP showed impressions, but I wasn't able to see the popup.

<form id="mktoForm_1589"></form>
<script type="text/javascript">// <![CDATA[
$.ajax({ 
cache: true, 
async: true, 
url: "//app-sj05.marketo.com/js/forms2/js/forms2.js", 
dataType: "script", 
success: function(){ 
MktoForms2.loadForm("//app-sj05.marketo.com", "867-SLG-901", 1589); 

});
// ]]></script>