7 Replies Latest reply on Feb 3, 2015 10:37 AM by 00a1d7df772c573530f315557f16b22efeeb8aac

    Submit Marketo form and stay on page to display "thank you" messaging-script not working

      I have an onSubmit function to submit leads into Marketo (had to do some customizing to load form data into Salesforce); I tried adding the onSuccess code to have the form stay on the page after form submission, hide the form and show a thank you div instead. However, it isn't working... the form stalls as it's submitting and does not submit anything (the submit button has become inactive).

      Any thoughts? Thanks!

      <script>MktoForms2.loadForm("************", "*****", ****,
      //Add the hidden fields for Calculator Quote URL
          var currentURL = window.location.href;
            form.addHiddenFields({"Calculator_Quote_URL__c":currentURL, "Company":"", "Lead_Created_Date__c":""});

          //add an onSubmit handler
              //Fill in the hidden company field for SF
              $('[name="Company"]').val($("#LastName").val() + ', ' +  $("#FirstName").val());
              //Get the current date and insert into lead created date for SF
              var today = new Date();
              var dd = today.getDate();
              var mm = today.getMonth()+1; //January is 0!
              var yyyy = today.getFullYear();

              if(dd<10) {

              if(mm<10) {

              today = mm+'/'+dd+'/'+yyyy;
              //get the form field values
              varvals = form.getValues();
           //Add an onSuccess handler
           //get the form's jQuery element and hide it and show thank you
                  document.getElementById('confirmform').style.visibility = 'visible';
               //return false to prevent the submission handler from taking the lead to the follow up url.    
              return false;