Dynamically change question text based on selected choices | XM Community
Skip to main content

Dynamically change question text based on selected choices

  • June 26, 2019
  • 2 replies
  • 180 views

ambrubaker
Level 1 ●
Forum|alt.badge.img+2
I have a survey with a list of options that users select in the first block. In the next block, I am using a combination of loop and merge and display logic to present the survey participant with a series of text entry fields. Depending on the options they selected in the first question, I want to insert language/text to specify what should be entered. For example, the question on the second screen is labeled "Name." However, this field may display if a respondent selects "Participated in a job shadow" or "Attended a networking event." If the respondent selects "Participated in a job shadow," I want the question on the second screen to display "Name of Person You Shadowed." If the respondent selects "Attended a networking event," I want the question on the second screen to display "Name of Event." The list of options has 58 possible values but a respondent will never see more than 9 because I am using embedded data and display logic to show only the relevant options. The only method that I have found that works for changing the label names, is to use branch logic and set additional embedded data elements in the survey flow. This is laborious and seems like there should be an easier way to accomplish this with some JavaScript. Any suggestions and ideas are welcome.

2 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • June 26, 2019
I don't know if it will be any less laborious, but instead of setting the embedded data fields with survey flow branch logic you could set them in a addOnPageSubmit function attached to the question on your first screen based on the answers selected in that question.

ambrubaker
Level 1 ●
Forum|alt.badge.img+2
  • Author
  • Level 1 ●
  • June 26, 2019
> @TomG said: > I don't know if it will be any less laborious, but instead of setting the embedded data fields with survey flow branch logic you could set them in a addOnPageSubmit function attached to the question on your first screen based on the answers selected in that question. Would you happen to have an example of what that code might look like?