SOLVED

Dynamically fill a field in a form

Go to solution
Anonymous
Not applicable

Dynamically fill a field in a form

I have a Marketo form embedded on our website, I'm wondering if it's possible to dynamically fill an input field with text using jQuery? The web page that contains the embedded form is on a non Marketo hosted web page.

Here is the jQuery that I'm currently attempting to use:

var text = "Hello World";

$('#FirstName').val(text);

So far, I haven't had any luck getting this to work. It works on non Marketo forms such as Gravity Forms.

Thanks in advance for any help!

-Brandon

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Dynamically fill a field in a form

Marketo Forms has its own API which should always be used (check the docs on developer.marketo.com).

You want

MktoForms2.whenReady(function(form){

    form.setValues({FirstName:'Hello World'});

});

View solution in original post

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Re: Dynamically fill a field in a form

Marketo Forms has its own API which should always be used (check the docs on developer.marketo.com).

You want

MktoForms2.whenReady(function(form){

    form.setValues({FirstName:'Hello World'});

});

Anonymous
Not applicable

Re: Dynamically fill a field in a form

Hi Sanford,

Where should I look in the docs for this type of thing? I've gone through the API but couldn't seem to find anything to fill this need.

Thanks!

SanfordWhiteman
Level 10 - Community Moderator

Re: Dynamically fill a field in a form

The Forms 2.0 API, not any of the other APIs. It's one of the choices in the left nav on the developer site.

Anonymous
Not applicable

Re: Dynamically fill a field in a form

Thank you so much!!!