Community Groups are officially here!
We've released Groups, a new feature that enables us to connect community members of similar industries and interests in a shared, private space. You can check out all of the details here, including information about who can join, how to join, and what Groups are currently offered. Please leave your feedback through this Community Groups Feedback Survey.

Dynamically change slider start position

cm201623
cm201623 Community Member Qubie ✭

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!!!

Answers

  • cm201623
    cm201623 Community Member Qubie ✭

    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

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭

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

  • cm201623
    cm201623 Community Member Qubie ✭

    Thanks. 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);
    });
    
  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭

    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.

  • cm201623
    cm201623 Community Member Qubie ✭

    Is there any way to use setChoicevalue to set subsequent question's choices?

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭

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