Dynamically filtering lists of multiple-choice options
As discussed in their respective help topics, you can use select_one and select_multiple fields to ask multiple-choice questions, and you can specify all of the valid choices in the choices sheet of your workbook. In the standard case, every user answering a multiple-choice question is always shown every available option.
However, it is also possible to filter the list of options shown to users, based on their prior selections. Such filtering is made possible by a feature called "cascading selects."
In the form designer, you can add a filter value for any multiple-choice option, and you can add a choice_filter expression for any multiple-choice field – but you'll need to choose those filter values and expressions as discussed below, in the much the same way you would if you were editing the spreadsheet form definition directly.
Click here to watch a video on how to create a basic choice filter.This feature is best explained in the context of a simple example form, which you can select as a starting-point when you click + and then Start new form to start a new form from the Design tab: enable the Use a sample form as your starting point option, then choose Cascading selects: Filtering multiple-choice option lists from the list of samples available. In this example form, the user is asked to select the survey region, then the country, then the city. All of these are simple select_one fields, but they have been configured to filter the options so that the country list is appropriate to the selected region and the city list is appropriate to the selected country.
To filter the country and city lists, two special columns are used:
- The filter column on the choices sheet. For countries, this column contains the region code for which each country should be listed; for the cities, it contains the country code for which each city should be listed. The values specified in the filter column correspond to the values specified earlier in the value column (i.e., you filter by the internal values stored in the form data, not by the choice labels).
- The choice_filter column on the survey sheet. This specifies, for each field, which prior field should be used when filtering the list of options. For the survey_country field, the choice_filter is "filter=${survey_region}"; this means that, when showing the country list, SurveyCTO should compare the filter column of the choices sheet with the user's selection from the survey_region field – and only show those choices for which the filter matches (i.e., for which the given filter expression is true). The choice_filter for the survey_city field is "filter=${survey_country}", so that only those cities in the selected country are shown.
For more details about this example, see Cascading selects: Filtering multiple-choice option lists.
More advanced usage is also possible. For example, rather than having just one filter column in the choices sheet, you could have more than one, each with a unique name (e.g., filter_region and filter_country). You could then specify more complex expressions in the choice_filter column of the survey sheet (e.g., "filter_region=${survey_region} and filter_country=${survey_country}"). However, a single filter column works for most cases, and the online form designer only supports a single one.
For an example where the filtered choices have dynamic labels, see Rosters: Choosing among earlier entries. (That particular sample also demonstrates that you can use different types of expressions for the choice_filter expression, as in its "${numfamily}>=filter" expression.)