Dynamically change slider start position | XM Community
Skip to main content

Hi, I want to dynamically change a slider's start position.
For example, the participant's first response is 200, I want to hide the slider and then after 60 seconds, I want to show the slider and the start position is at 200-60=140, the participant can drag the slider to 100. Then after 60 seconds, I want to set the slider start position at 100-60=40. What tricks can I use to dynamically change a slider's start position from 200 to 140 then to 40?
I know the slider start position can be customized by using javascript:
var qobj = this;
var qid = this.questionId;
this.setChoiceValue(1, 140);
But this cannot work with the setTimeout function: This doesn't work
setTimeout(function(){
this.setChoiceValue(1, 140);
},60000);
And I cannot separate these slider questions into several blocks because there are other questions in this block and I want to keep people within the same block to observe something and see other questions.
Is there any way to do this? Many thanks!!!

Another question is when I tried to use several slider questions: use settimeout function in slider 1 to control the display of slider in next question, I find the slider in the second question cannot be moved.
Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery("#QID47").hide();
setTimeout(function(){jQuery("#QID47").show();}, 5000);
});

QID47 is the second slider question. And its bar cannot be moved. Here is the preview link


Hiding messes with how Qualtrics sets up the slider. Reduce the opacity if you want to hide it from the respondents.


https://community.qualtrics.com/discussion/comment/38358#Comment_38358Thanks. May I ask do you know how to dynamically change the slider's start position? It seems like this.setChoice value doesn't work with the settimeout function.
setTimeout(function(){
this.setChoiceValue(1, 140);
},60000);
Or I can set two questions, but how can I set the second question's slider in the first slider question's javascript? I used the following codes but it doesn't work. QID47 is the second question. I used these scripts in the first question, it says jQuery... is not a function.
var qobj = this;
var qid = this.questionId;
jQuery( "#"+qid ).on('change', function(){
var response = parseInt(jQuery("#"+qid+"\\\\~1\\\\~true-result").val());
jquery("#QID47").setChoiceValue(1, response);
});


it says jQuery... is not a function.
Read your code again till you see why.
SetChoiceValue will not work JQuery, it's an internal Qualtrics method.
this.setChoiceValue(1, 1, 140) should work. But it won't inside the setTimeout due to scoping.


https://community.qualtrics.com/discussion/comment/38385#Comment_38385Is there any way to use setChoicevalue to set subsequent question's choices?


Qualtrics.SurveyEngine.registry["QID147"].setChoiceValue(...)


Leave a Reply