SOLVED

Re: Need debugging help

Subscribe
Go to solution
Robb_Barrett
Level 10

I've spent far too long looking at this and not figuring out why this isn't behaving properly.  Why is this causing my entire page to reload?  It should just hide the form and show the thank-you page. I've run similar code many times on my other instance of Marketo with no problems.  This one is weird though...it does the onSuccess action of hiding the form, the preform-div and showing the postform-div but then moments later the entire page reloads. I thought the return false prevented that.

http://it.gehealthcare.com/rad-ciet-trucktour-shortform.html

if (window.location.href.search('{{my.Alternate-Page-Name}}') >-1) {

  var formNum = {{my.Alternate-Form}};

  document.getElementById("form-div").innerHTML = document.getElementById("alternateForm-html").innerHTML;

  document.getElementById("preform-div").innerHTML = document.getElementById("alternate-preform-html").innerHTML;

  document.getElementById("postform-div").innerHTML = document.getElementById("alternate-postform-html").innerHTML;

  document.getElementById("headline-div").innerHTML = document.getElementById("alternate-headline-html").innerHTML;

} else {

  var formNum = {{my.Main-Form}};

  document.getElementById("form-div").innerHTML = document.getElementById("mainForm-html").innerHTML;

  document.getElementById("preform-div").innerHTML = document.getElementById("main-preform-html").innerHTML;

  document.getElementById("headline-div").innerHTML = document.getElementById("main-headline-html").innerHTML;

    document.getElementById("postform-div").innerHTML = document.getElementById("postform-html").innerHTML;

}  

document.getElementById("postform-div").style.display = "none";  

  MktoForms2.loadForm("//app-aba.marketo.com", "406-TVZ-560", formNum,

      function(form) {

      form.onSuccess(function(values, followUpUrl) {

        form.getFormElem().hide();

        document.getElementById("preform-div").style.display="none";

        document.getElementById("postform-div").style.display="block";

        });

  return false;

    });

Robb Barrett
1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator

Your ​return false; ​is outside the onSuccess listener, so the default success action will take place.

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Your ​return false; ​is outside the onSuccess listener, so the default success action will take place.

Robb_Barrett
Level 10

You know it's Friday when the answer is "Parenthesis in wrong place."

Thanks Sandie. 

Robb Barrett