Skip navigation |

How to make the values in a dropdown change depending on the value chosen in another dropdown

You can make dropdown questions present a different list of values depending on what the user has selected in another question on your forms. Follow these steps to learn how.

Last updated: 09 May 2012, 15:55

Sometimes you want to allow a user to choose from a dropdown list whose contents depend on a value that the visitor has already chosen in a previous dropdown.

Setting this up is really easy. The examples below show how this works and explain how it is done.

A quick example

This example asks you to choose what kind of animal you like and depending upon your first answer, asks you to select which breed of that animal you prefer.

How to set it up

To create your own dropdowns that depend on others, follow these steps to create a question that asks you to choose what type of food you like. Depending on what you choose, you are presented with a different set of options in the next question.

The master question

This question is the 'master'. This is just a standard dropdown. It is really important that you give this question a 'Name'.

We have set the following properties on this question:

Name: "foodType"

Parameters: "Biscuits;Ice Cream;Takeaway"

The dependant question

This is the question whose values change. It is defined just like a normal dropdown in that you specify the allowed values in the 'Parameters' box, separated by semicolons.

Again, it's really important that you give this question a 'Name'.

To tell the dropdown what it is linked to, the first allowed value must be in the format "=xxxxx" where "xxxxx" is the 'Name' of the field we created above. In this example, we will use =foodType

Next, specify the values that you want to show for the first item in the master list. Do this by adding an allowed value in the format "=yyyyy" where "yyyyy" is the text of the item in the parent dropdown for which you are listing values. In our example, the first item is "Biscuits", so we'll add "=Biscuits".

Now, specify each of the allowed values for the value you're adding. We'll add Bourbon, Digestive, Nice, and Custard Cream by separating them with semicolons in the usual manner: "Bourbon;Digestive;Nice;Custard Cream".

Carry on in this way for each of your other master values. You will eventually end up with something like this:

Name: "favouriteFood"

Parameters: "=foodType;=Biscuits;Bourbon;Digestive;Nice;Custard Cream;=Ice Cream;Vanilla;Triple Choc Chunk;Strawberry;=Takeaway;Indian;Chinese;Pizza;Fish and Chips"

Try it yourself - choose an item in the top dropdown and see the values in the bottom one change.

There's no end to how many dropdowns you can link together. You can have chains of questions just by following the steps above. Let us know if you need any help!

 

Cookies are used by nearly every website to improve your web browsing experience. Recent government legislation (the e-Privacy Directive) means that we are obliged to seek your agreement to the use of cookies when you visit our website. Two of the cookies that we use are essential for this website to operate and have already been set. You may delete and block all cookies from this site, but if you do so, parts of the site will not work. To find out more about the cookies that we use, please see our privacy policy.