SOLVED

Re: Pre-populating picklist value on Form

Go to solution
Liz_Nguyen1
Level 3

Re: Pre-populating picklist value on Form

Hi @SanfordWhiteman  - How can we achieve the same behavior for pre-populating a value for a field if on the form that field type is a dropdown picklist for another field on the form? Could we use the same code but swap out Product Interest for a different field? Or would we need to modify to accommodate the field type (dropdown)?

SanfordWhiteman
Level 10 - Community Moderator

Re: Pre-populating picklist value on Form

The field type doesn’t matter as long as the value(s) you set match existing options.

Liz_Nguyen1
Level 3

Re: Pre-populating picklist value on Form

Hi @SanfordWhiteman ! Thanks for replying. We were able to swap out the my.token reference and value and it did work for a dropdown picklist vs. checkboxes. Was just wondering, if we wanted to set the Primary Product Interest and Secondary Product Interest default values upon page visit. How would we modify the code you provided to account for both field references? Tried to duplicate the code twice for each my.token reference but it didn't work so I figure it's the way we have it setup that broke it.

 

Once again, appreciate your wealth of knowledge! It's been really helpful with getting those default values pre-populate on the form.

SanfordWhiteman
Level 10 - Community Moderator

Re: Pre-populating picklist value on Form

 

  readyForm.setValues({
    ProductInterest: marketoTokens["my.Product Interest"].value,
    SomeOtherField: marketoTokens["my.Some Other Field"].value,
    YetAnotherField: marketoTokens["my.Yet Another Field"].value
  });

 

Assuming your have the {{my.tokens}} in the <datalist> of course.