SurveyCTO Dynamically Populated Choice Lists From Select One
Best Practice
Sometimes we want to ask a respondent to select one or several answers out of answers the respondent have given earlier in the interview. For example, we might want to ask who in the household out of the household members listed in the household roster module is currently employed. It is possible to do this by dynamically load previous answers as answer options.
Any answer can be used in dynamic choice lists, but when using variables inside a repeat group, one more extra step is required. We cannot reference a field inside a repeat group directly.
Coding Example
Here is a code example of how the answers to a field inside a repeat group are used to dynamically load the answer options for a select_one or a select_multiple question.
This example dynamically load answers from a repeat group. If you were to dynamically load answers from fields not inside a repeat group, then you simple reference those fields directly in the choice tab.
Not that this coding example can be improved in many ways. It has excluded some possible improvements in order to highlight the functionality discussed in this article. The most obvious improvement would be to filter the answer options so that only the answer options needed are displayed. See the section about choice filters.
Back to Parent
This article is part of the topic SurveyCTO Coding Practices