SOLVED

Marketo Forms pre-fill when there are two forms in the same page

Go to solution
Ravindranathsa2
Level 1

Marketo Forms pre-fill when there are two forms in the same page

We have two Marketo forms in a single page and display of forms will be controlled based on mktoPreFillFields, something like this

MktoForms2.whenReady(function (form){

if(typeof mktoPreFillFields != "undefined" && !jQuery.isEmptyObject(mktoPreFillFields)){

/* Show form2 and hide form 1 */

}

}

With the new Marketo Form Pre-fill Feature upgrade​ we had to use Sanford Whiteman's solution for Pre-fill of forms. Unfortunately Pre-fill of forms is happening after the above function is executed and only form1 is getting displayed every time. As there are two MktoForms2.whenReady() functions , is there a way to control the flow between the two like pre-fill executes first and then the above one?

Any suggestions are welcome. Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Forms pre-fill when there are two forms in the same page

The TEKNKL Pre-Fill library doesn't overwrite window.mktoPreFillFields. It uses a JS object that exists only inside the cb (callback) function.

Add your code above inside the cb if you want it to depend on the contents of mktoFields.

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Forms pre-fill when there are two forms in the same page

The TEKNKL Pre-Fill library doesn't overwrite window.mktoPreFillFields. It uses a JS object that exists only inside the cb (callback) function.

Add your code above inside the cb if you want it to depend on the contents of mktoFields.

Ravindranathsa2
Level 1

Re: Marketo Forms pre-fill when there are two forms in the same page

Thanks for the quick response Sanford. I have assigned values to mktoPreFillFields and then things worked as expected.