SOLVED

Add custom class to Marketo form submit

Go to solution
SanfordWhiteman
Level 10 - Community Moderator

Re: Add custom class to Marketo form submit

MktoForms2.whenReady(function(form){

  var formEl = form.getFormElem()[0];

  form.onSuccess(function(vals,tyURL){

    var tyLoc = document.createElement("a");

    tyLoc.href = tyURL;

    tyLoc.className = "om-trigger-conversion mchNoDecorate";

    formEl.appendChild(tyLoc);

    tyLoc.click();

    return false;

  });

});

Do i get rid of this??

<script>

MktoForms2.whenReady(function(form){

var formEl = form.getFormElem()[0],

submitEl = formEl.querySelector('input[type="submit"]');

submitEl.className += ' om-trigger-conversion';

});

</script>

Yes, you aren't using that method.  But please if posting code always use the syntax highlighter in Advanced Editor:

https://s3.amazonaws.com/blog-images-teknkl-com/syntax_highlighter.gif

Callum_Pirie
Level 3

Re: Add custom class to Marketo form submit

Hi Sanford thanks for this.

just to confirm the full code I am using is the code you added with 11 lines? Sorry just wanted to make sure.

Thanks again

SanfordWhiteman
Level 10 - Community Moderator

Re: Add custom class to Marketo form submit

Yes.

Callum_Pirie
Level 3

Re: Add custom class to Marketo form submit

Thanks again

Callum_Pirie
Level 3

Re: Add custom class to Marketo form submit

Sorry Sanford I tried the following but i'm obviously doing something wrong...

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

<form id="mktoForm_1145"></form>

<script>

   MktoForms2.whenReady(function(form){ 

  var formEl = form.getFormElem()[0]; 

  form.onSuccess(function(vals,tyURL){ 

    var tyLoc = document.createElement("a"); 

    tyLoc.href = tyURL; 

    tyLoc.className = "om-trigger-conversion mchNoDecorate"; 

    formEl.appendChild(tyLoc); 

    tyLoc.click(); 

    return false; 

  }); 

}); 

</script>

SanfordWhiteman
Level 10 - Community Moderator

Re: Add custom class to Marketo form submit

Please let me know the URL, and what is "obvious".

Callum_Pirie
Level 3

Re: Add custom class to Marketo form submit

Hi Sanford

the URL is

Professional Diploma in Digital Marketing | Study Online in Ireland | Enrol

its basically if you hover over the URL it will show the Optin

SanfordWhiteman
Level 10 - Community Moderator

Re: Add custom class to Marketo form submit

Where on that page do you have the code?

Callum_Pirie
Level 3

Re: Add custom class to Marketo form submit

If you hover over the URL the form will appear.

2018-10-16_09h09_34.png

SanfordWhiteman
Level 10 - Community Moderator

Re: Add custom class to Marketo form submit

I'm asking on what line of what file are you adding the Forms JS custom behaviors code above?