Dynamically fill a field in a form | Community
Skip to main content
December 2, 2015
Solved

Dynamically fill a field in a form

  • December 2, 2015
  • 1 reply
  • 1880 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

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'});

});

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
December 2, 2015

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'});

});

December 2, 2015

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
New Participant
December 2, 2015

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.