In this article
This functionality allows you to use logic within a page, and enables parts of a page to be updated based on responses to one or more questions on the same page. This can enable you to, for example, cause additional questions to appear on the page once the respondent has answered the first question. The functionality is based on the Ajax technology, and uses one (or more) questions as a trigger to activate logic in subsequent questions.
Note: Dynamic Questions only functions within page objects, and the trigger question(s) and the question(s) to be triggered, must be on the same page in the survey. Triggers are not available for Chart nodes.
Any logic created using the other functionality within Forsta Plus, such as text piping, question masking etc. can be controlled by the trigger function.
Note: "Dynamic Questions" is supported in IE8+ (Windows), Firefox 10+, Google Chrome 26+ and Safari 5.1+ (Mac only). This functionality is only available in surveys using Survey Layouts (go to About Survey Layouts for more information). If a Survey Layout is not used, then the page layout will be static and the questions will appear on the same page. However as the logic is only evaluated when the page is submitted (when the respondent clicks the Forward button), an error message may result if for example one of the initially hidden questions is missing a response. There is therefore no fall-back for Dynamic Questions. However the DynamicQuestionsEnabled() function can be used to either screen or create an optional routing for respondents who do not have the required browser.
Touch device (iPhone and Android) enabled surveys support dynamic triggers. For touch devices, pages containing dynamic triggers will always appear on the same page irrespective of the "One question per page" touch setting.
Example Using Dynamic Questions
Below is an example demonstrating the use of the Dynamic Questions functionality.
Assume we wish to start a Survey by initially showing just one question on a page, asking the respondent to type in his/her name. Then once the respondent has typed in their name, we want a second question to appear on the same page, asking the respondent, by name, to input their gender.
To do this we first need to create a Page object in the Survey tree, and then within that page we need to create two questions; the "Name" question and the "Gender" question. For the Gender question, we need to pipe the respondent's name into the question Text, we need to mask the question until the respondent has input their name (the answer is Boolean), and we need to set the trigger such that the Gender question's masking is activated by the Name question. Proceed as follows:
- Create your survey (or open it if it already exists), and create a page in the appropriate place.
- In the page, create an Open question and a Single question - .
- Set up the first question on the page (in this case q2) as required to ask the respondent to input his/her name.
- In the second question on the page (q3) pipe the answer from q2 into the text of q3 - .
- Go to the Answers tab and set up the answers as required.
- Go to the Trigger tab, and type in the Question ID of the question you wish to use as the trigger - in this case q2 - .
- Go to the Masking tab, and in the Question Mask field type the masking expression you wish to be run.
- Save the changes.
- Right-click on the survey in the Survey Tree and select Quick Test > Quick Test (with rebuild) from the menu. The results should be as shown below.
Figure 1 - The page containing the two questions
Figure 2 - Piping the answer text from q2 into q3
Figure 3 - Setting the Trigger
In this case, you want q3 to be displayed once q2 has been answered. The expression required therefore needs to check whether the answer to q2 is Boolean (is not empty), and if the result is TRUE, then to show the question - .
Figure 4 - The masking expression
Figure 5 - The page before the Name question is answered
Figure 6 - The page after the Name question is answered
When q2 is changed the part of the page that contains q3 will be refreshed, so any changes will be updated immediately.