How to display text (within a question) conditional on embedded data? | XM Community
Question

How to display text (within a question) conditional on embedded data?

  • 12 November 2020
  • 1 reply
  • 1055 views

Badge

I'm familiar with piped text, I'm asking for something different here.
The experimental condition I'm using makes it really inconvenient to just use branching and display logic for every single question. What I need is to have text within a question that is displayed, or not displayed at all, as a function of a particular embedded data variable. That variable here is called "Condition."
For example, I'll use different types of brackets in the following sentence to indicate the text that is contingent on the value of the Condition embedded data variable:
This is text that I want everyone to see, but <this is text that I only want people in condition 1 to see> [this is text that I only want people in condition 2 to see].
As you can imagine, it would be a bit of a pain to have double the number of questions in the survey rather than containing all the info in one question.
At one point a while ago, I thought I was just going to make the text conditional on the answer to the previous question, and someone suggested the following:

In question text (HTML view):


 
In JavaScript (Onload section):
selected="${q://QID1/ChoiceGroup/SelectedChoices}";

//selected=selected.replace(/ /g,"");

selected=selected.replace(/[\\.,\\"\\'\\:\\-”“‘’ ]/g,"");

//alert(selected);

jQuery('.' + selected).show();



However, I don't know JavaScript at all, so I don't know if or how this could be modified to use embedded data rather than the answer to the previous question.


1 reply

Userlevel 7
Badge +27

Hi there, if you still need, I found a thread that I think will be helpful to you. In that, lizb311 and ahmedA provide 2 methods that can change the Question text based on Embedded data. One uses Survey Flow and piped text, the other uses JavaScript.
https://community.qualtrics.com/XMcommunity/discussion/14197/is-it-possible-to-dynamically-change-the-question-text-based-on-an-embedded-field-value

Leave a Reply