0 Replies Latest reply on Aug 11, 2016 8:25 AM by 675718fdbe434ab284fb12ae831049e50bf24dbe

    How to prevent Marketo form from loading twice?

      Hi everyone, not too great with javascript, and looking for help from anyone who is willing to.

      I have a Marketo form code that works great on all my pages. It is responsive and displays a message after submit. I was assigned to create a form also to be loaded from a modal/lightbox. But every single time I close the lightbox and load it again, the form is being displayed twice.

       

      So my question is, how would I in a way clear my form after closing lightbox? Or reset all values after on load? Does this make sense? I want the form to load only once every time it is being called. Thanks for your help.

       

      Code:

       

      <body>

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

      <script>MktoForms2.loadForm("//app-sj08.marketo.com", "861-RWS-699", 1261, function(form) {});</script>

       

         

       

       

                <div class="boxPadding" style="background-color:#FFF; margin:0px 40px 0px 40px;">

       

       

             

              <!--  1 COLUMN-->

             

                            

                  <form id="mktoForm_1261"></form>

       

       

                  <ul class="mktoUL">

                                  <li>

                                  <p id="confirmform" style="visibility:hidden;"><span class="paddingArticlePage"><span class="paragraphArticlePage"><b>Thank you. You are now subscribed to Nanette Abuhoff Jacobson Commentary.</b></span></span></p>

                                  </li>

                              </ul>

       

       

       

       

       

       

                <!--  END 1 COLUMN-->

       

       

               

          </div>

         

        

          <!-- on submit hide form and show hidden div -->

         

       

       

      <script>

      MktoForms2.whenReady(function (form){

       

       

      //Add an onSuccess handler

        form.onSuccess(function(values, followUpUrl){

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

         form.getFormElem().hide();

      document.getElementById('confirmform').style.visibility = 'visible';

         return false;

      });

      });

      </script>

       

       

      </body>