The dynamicoptions
tag narrows the selectable options of a question based on the response of another question, or trigger. This is useful for a follow-up question that contains a large set of options, but only some of those options apply to some respondents. Respondents answer a first question, which dynamicoptions
uses to automatically filter the possible answer choices of a subsequent question. These questions typically are located on the same page.
Syntax
The syntax for dynamicoptions
is made up of various brackets and other symbols:
dynamicoptions: <trigger>, { <trigger opt1> => [ <target opt1>, <target opt2> ], <trigger opt2> => [ <target opt3>, <target opt4> ] }
Note: The order of the options are controlled by the list of options, not the order in which the options are referenced in the dynamicoptions
script. To rotate or change the order of the options, change the order manually in the list before compiling, or use an order
tag to control the rotation.
Examples
Pulldown
In the example below, Q1 presents three colors to choose from. Q2 uses the dynamicoptions
to filter the visible options based on the response to Q1. For example, if the respondent chose '202 - Green' at Q1, then the options at Q2 are filtered automatically to only show '4 - Red-lored Parrot', '5 - Lucifer Hummingbird', '6 - Common Peafowl', and '97 - Other'.
Radio
The example below uses dynamicoptions
on a radio question, and is controlled by a checkbox question.
Hiding options for radio and checkbox questions
When using radio or checkbox question types, the options are disabled and grayed out instead of hidden as in a pulldown or listbox question type. To hide the options instead, add CSS to your page or your stylesheet.
.i-opt-disabled { display: none !important; }
Comments
0 comments
Please sign in to leave a comment.