7 Replies Latest reply on Sep 11, 2017 10:04 AM by Sanford Whiteman

    multiple JavaScript embedded forms on a page

    Kristopher Maier

      We have a need to have multiple pages on a single webpage. They way the page works is there an initial form that needs to be filled out to access "gated" content, upon submit it would hide/reveal certain content. we would like to add a second form the user could follow up with if they have further questions. My snag is when I enter the JavaScript to the page both forms submit to the last script to load on the page. Any idea how I can get multiple forms to submit to the desired URLs?

       

      Here is how I am loading the forms:

      <script type="text/javascript">
      MktoForms2.loadForm("//app-***.marketo.com", "***-***-***", 1354, function (form) {
      MktoForms2.$("#formPlaceholder_1354").append(form.getFormElem());
      // Set values for the hidden fields
      form.vals({"productLine":"<%# Eval("ProductLine") %>","application":"<%# Eval("Application") %>","industryType":"<%# Eval("Industry") %>"});
      });
      
      //go to URL on submit
      MktoForms2.whenReady(function(form){
      
          //Add an onSuccess handler
          form.onSuccess(function(values, followUpUrl){
            //Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl.
            location.href = "/treating/thank-you.aspx";
            //return false to prevent the submission handler continuing with its own processing
            return false;
          });
        });
        </script>
      


      Thanks!