Populate country in form field based on country selection in same form | Community
Skip to main content
Kiah_Kennedy
Level 2
May 22, 2018
Solved

Populate country in form field based on country selection in same form

  • May 22, 2018
  • 2 replies
  • 4966 views

I have a form that asks users to consent to their data being processed by a variable entity based on their country. I need to setup the form so that once a lead selects their country from the dropdown, the in the next field dynamically populates the entity with the country.

So for eg. I as a lead, go to this form. I select Canada as my country from the dropdown. Once I do that, the next field in the form dynamically autopopulates this text: "I consent to (company name) Canada to use my data"

I tried to accomplish this by using the lead country token within the form but it sometimes showed the default value even when country was filled out for a lead. Sometimes it worked.

Also important to note is that this is a guided landing page, and the dynamic content is contained within the form, not on the landing page.

Any help is appreciated!!

Best answer by SanfordWhiteman

Exactly like so:

MktoForms2 :: VRs and templated output

Where the HTML of the output field's label is:

I consent to SpenceCo <output for="Country" name="brandedConsent"></output> using my data.

And the Visibilty Rule:

2 replies

Grégoire_Miche2
Level 10
May 22, 2018

Hi Kiah,

Tokens will not help here. They could only be populated after the form is submitted to the database.

You will need some javascript to do this.

-Greg

Kiah_Kennedy
Level 2
May 22, 2018

Hi Gregoire, thanks for your reply! What if we already have the lead country in our database? It worked a few times with tokens but other times it showed the default value even when we already had country populated for that lead in our database. Is this the behaviour you would expect? Thanks so much!!

Grégoire_Miche2
Level 10
May 22, 2018

Hi Kiah,

Is the lead country is in the database, the token will populate, but I do not recommend you do this: if the person updates her country the token will not be updated.

The default value might be explained if you have duplicates in your database, or if the lead cannot be identified with the munchkin cookie.

-Greg

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
May 23, 2018

Exactly like so:

MktoForms2 :: VRs and templated output

Where the HTML of the output field's label is:

I consent to SpenceCo <output for="Country" name="brandedConsent"></output> using my data.

And the Visibilty Rule:

Grégoire_Miche2
Level 10
May 23, 2018

Nice one

-Greg