conditional display | XM Community
Skip to main content
Hello, I'm looking to display some wording on a question based on the answers of another previous question. is there a way to do this without having to do several blocks with embedded data?

Example Q1=Yes/No/DK, Q2 Display “All” if Q1=No/DK display “The” if Q1=Yes

Wrap the part of question with span tag. Assign a class to span tag. Now, use JS in the follow-up question to read the recode value of the selected answer in the previous question and update the span tag based on the condition. Below is the example:

Question HTML:

<span class="dynamic">All</span> question text goes here....

Question JS:

if("${q://QIDXX/SelectedChoicesRecode}"==1 )
jQuery(".dynamic").text("The")
else
jQuery(".dynamic").text("All")

 


You can use piped text or display logic also 


Thanks for your anwer @Shashi @krbhavya 

@Shashi how can i difference the language like this (how to capture the selected language?) :

 

if(("${q://QID1152/SelectedChoicesRecode}"==12 ) or ("${q://QID1152/SelectedChoicesRecode}"==22 ) or ("${q://QID1152/SelectedChoicesRecode}"==23 )) and LAN==EN-GB
        jQuery(".dynamic").text("When using services, how would you rate the ease of start-up?")
else
        jQuery(".dynamic").text("When using equipment, how would you rate the ease of start-up?")
        
endif


Thanks for your anwer @Shashi @krbhavya 

@Shashi how can i difference the language like this (how to capture the selected language?) :

 

if(("${q://QID1152/SelectedChoicesRecode}"==12 ) or ("${q://QID1152/SelectedChoicesRecode}"==22 ) or ("${q://QID1152/SelectedChoicesRecode}"==23 )) and LAN==EN-GB
        jQuery(".dynamic").text("When using services, how would you rate the ease of start-up?")
else
        jQuery(".dynamic").text("When using equipment, how would you rate the ease of start-up?")
        
endif

By reading Q_Language Embedded data in the JS


As @krbhavya mentioned above, piped text and display logic is a good choice if you don’t code. It depends on what you are trying to do:

If you want to display a question based on responses to earlier questions (for example: if question 1 is “what is your favorite major league sport” and for question 2 you want the respondent to choose their favorite football team, if they chose “football”, you can set up display logic to only display question 2 if the response to question 1 is “football”. You can use this to create similar but different questions; so for example, question 3 in the sequence could ask about baseball players, if the respondent chose “baseball” as their favorite sport, question 4 if the respondent chose “cricket”, and so on.

Piped text is a little bit different--it can fill in specific fields with text from previous responses or embedded data. So, for example, if in Question 5 you ask a fill in the blank question such as “who is your favorite baseball player, you can pipe that response into Question 6 which would ask a multiple choice question about why there respondent likes that baseball player.

It sounds like display logic may fit your use case better-I hope this helps!

 

 


Leave a Reply