Autofill a Text Field with a Cookie Value | Community
Skip to main content
Joseph_Moran2
Level 2
August 21, 2018
Solved

Autofill a Text Field with a Cookie Value

  • August 21, 2018
  • 1 reply
  • 3498 views

We have an old shopping cart we are looking to move into Marketo. The vendor we are working with wants to store color choices in a cookie and when the embedded form loads, pass the stored color values from the cookie into a text field. I can see that this should theoretically work for a hidden field, but we want the user to see the values they chose before submit. So I want the field to be displayed.

Is this possible? Can we autofill a text field or display the hidden field on the embedded form?

Hoping @Sanford Whiteman​ might have some thoughts on this. The vendor initially wanted to use the REST API to post to Marketo, but I discouraged that based on what I read on the community about it being a potential security risk.

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

Yep, definitely no reason for a back-end API to be used for this function (and it would be very complex to build that way due to timing issues). It can be built easily using the Forms JS API. 

You're right that the built-in AutoFill from cookie only works w/fields of the Hidden type.

But you can make AutoFill work with regular, visible fields too. Exactly like this: MktoForms2 :: AutoFill from cookie

Just download and include the FormsPlus utility script (in the HTML pane) and follow the concept in the JS pane.

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
August 22, 2018

Yep, definitely no reason for a back-end API to be used for this function (and it would be very complex to build that way due to timing issues). It can be built easily using the Forms JS API. 

You're right that the built-in AutoFill from cookie only works w/fields of the Hidden type.

But you can make AutoFill work with regular, visible fields too. Exactly like this: MktoForms2 :: AutoFill from cookie

Just download and include the FormsPlus utility script (in the HTML pane) and follow the concept in the JS pane.