Skip to main content
Robb_Barrett
Level 10
March 11, 2016
해결됨

Need debugging help

  • March 11, 2016
  • 2 답변들
  • 2072 조회

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;

    });

이 주제는 답변이 닫혔습니다.
최고의 답변: SanfordWhiteman

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

2 답변

SanfordWhiteman
Level 10
March 11, 2016

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

Robb_Barrett
Robb_Barrett작성자
Level 10
March 11, 2016

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

Thanks Sandie. 

Robb Barrett