8 Replies Latest reply on Jul 9, 2018 12:54 PM by Kristin Antoszz

    Custom Javascript for Specific Form on a Page with Multiple Forms

    Tracey Bartz

      We are building a new microsite in Wordpress and adding Marketo forms on each page using the "Marketo Forms and Tracking" plugin. Most of the pages of the site have two forms: one for the primary CTA and one for a secondary CTA. These are set up as different forms in Marketo with different fields. My developer has wrote custom javascript that says:

      • After all forms have rendered on the page
      • If the submit button is clicked
        • Replace the form with text
        • Block the redirect instructions set in the form editor in Marketo and instead execute the redirect landing page in a new browser window

      The issue we are running in to is that the Javascript is being applied to BOTH forms on the page. When we include the form ID in the Javascript, the JS doesn't execute at all. We've tried including the form ID using an "if" statement and using the ID as an array, string, and number type but none of those options seem to work. 

       

      Has anyone else run into this issue and/or have any suggested fixes so we can apply custom JS to only one form on the page?