10 Replies Latest reply on Apr 27, 2017 10:32 AM by Arlen Walker

    Load embedded form twice on the same webpage

    Valerie Armstrong

      Hello Community -

       

      We are working on a blog redesign and are using an embedded Marketo form on our blog to sign up subscribers.  We want to have this form appear twice on the page, once at the top and at the bottom of the blog posting. However, when we do this, the form is duplicating in both places. 

      2015-08-14_1005.png

       

      Anyone know what is causing this and how to fix it? (our blog is hosted on ExpressionEngine).

       

      Thanks!

        • Re: Load embedded form twice on the same webpage
          Pavel Plachky

          Hi Valerie,

           

          the embed code for a form looks like this:

           

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

          <form id="mktoForm_1234"></form>

          <script>MktoForms2.loadForm("//xxx-xxx.marketo.com", "YYY-ZZZ-WWW", 1234);</script>

           

          If you place this code on a web page twice, then you have two <form> elements with the same ID on the same page, which is invalid HTML, according to specifications. So unfortunately you should abandon the idea even if you could make it work.

           

          To understand why the form is showing twice each time, here is what each line of the script does:

          Line 1: Reads Marketo Forms2 library

          Line 2: Creates an empty form placeholder

          Line 3: Draws the form at the location you specified on line 2.

           

          Since you have the same script in two places, then the line 3 is invoked two times. Each time the script runs, it searches the whole HTML document for the placeholder with the form ID. The script finds two such placeholders, and it draws the form in both places each times it runs. That is why you get 4 forms on the page.

           

          I hope it makes sense.

           

          Pavel

          1 of 1 people found this helpful