SOLVED

Autofill a Text Field with a Cookie Value

Go to solution
Joseph_Moran2
Level 2

Autofill a Text Field with a Cookie Value

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.

Joseph Moran
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Autofill a Text Field with a Cookie Value

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.

View solution in original post

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Autofill a Text Field with a Cookie Value

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.