Greetings --
I'm pretty pleased with the answer I came up with for a researcher this morning -- I used branching and embedded data to change the text of a subsequent question.
!
The "Surname" ED variable is inserted in the text of a subsequent question so that "Ryan's" last name is either Smith or Jones.
On preview, it works -- but is it the most elegant solution? Do I need to have all those branches?
Page 1 / 1
If applicable, you can eliminate one branch by setting a default value. Using your example:
Surname = Smith
If Red is selected:
Surname = Jones
Surname = Smith
If Red is selected:
Surname = Jones
We have many (>10) choices and corresponding text strings, so it looks like I was probably on the right track -- but thanks for reminding me about the Default @TomG!
Since you have a lot of choices, an alternative would be to use JavaScript to do the replacement (if you know how to code in JavaScript). The basic steps would be:
1. Add a span tag with an id where you want to do the replacement - `<span id='replaceThis'></span>`
2. Setup an array in JS (e.g. arr) with your replacement text corresponding to recode values of the question you are basing it on (recoding the choices starting with 0 makes this easier)
3. Pipe the selected recode into a JS variable (e.g. recode)
4. Update the innerHTML of the span tag with the appropriate array value (e.g. arr[recode])
5. Optionally, set an embedded variable to the appropriate array value if you want a record of what the replacement was
1. Add a span tag with an id where you want to do the replacement - `<span id='replaceThis'></span>`
2. Setup an array in JS (e.g. arr) with your replacement text corresponding to recode values of the question you are basing it on (recoding the choices starting with 0 makes this easier)
3. Pipe the selected recode into a JS variable (e.g. recode)
4. Update the innerHTML of the span tag with the appropriate array value (e.g. arr[recode])
5. Optionally, set an embedded variable to the appropriate array value if you want a record of what the replacement was
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.