Display Logic based on Slider Answer? | XM Community
Skip to main content

Hello,
I'm trying to figure out how to code in a display logic based on an answer for a slider question. Essentially, I want a question to be displayed only if the participant selected an answer between 50-100 (slider scale is 0-100).
Additionally, the question is inside a randomized block (I used an advanced randomization) which I see how that adds a layer of complication to things. There are four questions inside the block and all should have the additional display logic. Any ideas on how to do this? Thank you!

Hi vvo ,

First thing you need to do is to keep your slider question out of the randomization block to avoid invalidation of display logic.
To set the display logic what you can do is, create a embedded data in survey flow and then capture the value of slider in the embedded variable and later use that variable for setting the display logic.
refer the screenshot below for more details:
image.pngimage.png


SaurabhPujare_Ugam Thanks so much!!
For some reason it's still not working. Below some screenshots. I followed your steps exactly -- I also included in the embedded field the answer field for each of the five questions (Question #6 is just an attention check). I also tried including the additional display question in another block but still did not work. Any idea on how I can include a display logic question within a randomized block for each of the five questions in the block? What am I doing wrong?
Screen Shot 2020-07-13 at 10.21.41 AM.pngScreen Shot 2020-07-13 at 10.21.56 AM.png


Hi vvo ,
You can achieve this using JS code, add the "Slider_selection" variable before the actual question in survey flow and add the below code in the JS of slider question.
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next")
{
jQuery('.ResultsInput').each(function(){
if(jQuery(this).val()>=50)
{Qualtrics.SurveyEngine.setEmbeddedData('Slider_selection',1)}
else{Qualtrics.SurveyEngine.setEmbeddedData('Slider_selection','')}
});
}
});
Now add the base logic to the question which you want to display if value is greater than or equal to 50 as if Slider_selection is equal to 1. In the above code "Slider_selection" will get assign to 1 if any of the option will have value 50 or more.


Leave a Reply