In this article, we will guide you on how to apply filters to show States/Provinces for a selected country or countries.
After inserting the dropdown element into the form, let's set up its data.
- Data Field: from your contact info address, pick up Country.
- Choice Set: from Geographic Location, pick up Countries. This will load up all the countries previously set up for this choice set.
- Insert your placeholder text, in this case "Select Your Country".
Now create a new choice set for the State/Province filtering. Go to Data Management > Data Collection > Choice Sets and click on New choice set category if you want to create a new one, or select one that you already have.
In this example, we've selected Geographic location as the category to then create a new choice set.
Insert a Label with an easy name for recognition afterwards and hit save.
After creating the choice set, set up a .csv file:
- In the first line and column of the spreadsheet, insert the text "choose one"
- Under this same column, write the name of the States
- After that, in the second column, you insert their abbreviation
- In the third column write the name of the Country
- After you finish to write down the States for one country, repeat the process for any other you might want to add (which will be separated from the Country above it by a new cell "choose one").
Here you can access a sample .csv file for reference.
Now import this spreadsheet to your choice set: select the choice set you've created and go to Choice Set > Import choice set.
Select the file to upload, make sure it is a .csv file, and hit save.
You choice set will look like this after importing the .csv file:
Back to the creative, select your State dropdown, go to Advanced Settings and then Dependent Data Field, that must be Country. This implies that the State options will only show up if the correspondent Country is previously selected.
Now, with the State dropdown still selected, apply the data field "State" to it and the choice set with the filter you just created:
- Refresh your page to load the new choice set available
- Data Field: from your contact info address, pick up State
- Choice Set: in our example, from Geographic Location, we picked up Country - States/Province Filter (the choice set we have just created). This will load up all the states previously set up for this choice set
- Insert your placeholder text, in this example "Select Your State"
After that, you can test your set-up. By selecting Azerbaijan, in this example, the State dropdown will not show up since this country is not within the choice set.
On the other hand, if we select Brazil, Canada or United States, the States will become available.
If you have any questions, please contact us on firstname.lastname@example.org. 😀