Need debugging help | Community
Skip to main content
Robb_Barrett
New Participant
March 11, 2016
Solved

Need debugging help

  • March 11, 2016
  • 1 reply
  • 2050 views

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.

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;

    });

Best answer by SanfordWhiteman

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

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
March 11, 2016

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

Robb_Barrett
New Participant
March 11, 2016

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

Thanks Sandie. 

Robb Barrett