1 Reply Latest reply on Aug 21, 2018 5:53 PM by Sanford Whiteman

    Autofill a Text Field with a Cookie Value

    Joseph Moran

      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.

        • Re: Autofill a Text Field with a Cookie Value
          Sanford Whiteman

          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.

          2 of 2 people found this helpful