Fill external forms 2.0 using javascript? | Community
Skip to main content
February 27, 2016
Question

Fill external forms 2.0 using javascript?

  • February 27, 2016
  • 2 replies
  • 1693 views

Hi there,

We have external pages in which we embed some of the Forms 2.0 JavaScript.

We would like to populate some hidden fields based on some server side code/data.

Can this be done? Perhaps using JavaScript? Any examples?

Thanks

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

2 replies

Josh_Hill13
Level 10
February 27, 2016

Probably with javascript and jquery. Consult developers.marketo.com and/or get a dev.

SanfordWhiteman
Level 10
February 27, 2016
We would like to populate some hidden fields based on some server side code/data.

Can this be done? Perhaps using JavaScript? Any examples?

Under the hood, Marketo forms are HTML forms equipped with a very handy JS API that lets you insert custom code and data at the right place and time.

Thus, any recipe that allows you to fetch data via JSON/XML (or even via variables "stamped" into the page on your server, with no additional HTTP calls) can be easily extended to insert the fetched values into hidden fields.

The real questions are what server you're fetching from and what format it uses when sending back data.  If the server you're fetching additional data from is the same webserver that hosts your embedded form, this makes things easier because you don't have to build in cross-domain compatibility (Jeff Coveney​ take note!).  But even across domains -- for example, your page at example.com is hosting a form from //pages.example2.com and bringing in hidden fields from //webservice.example3.com -- a skilled dev can make it all work.