Setting dynamic custom start position (NOT DEFAULT CHOICE) | XM Community
Solved

Setting dynamic custom start position (NOT DEFAULT CHOICE)

  • 25 August 2020
  • 3 replies
  • 227 views

Userlevel 5
Badge +7

I'm trying to set a dynamic custom start position for a slider, but do not want it to be set using the default choice feature. I want to be able to force a response from the respondent, but have the start position be preset dynamically. If I use the default choice feature, it sets the start position but also allows the participant to skip answering and simply click forward because it preselects the answer. Therefore, the default choice feature cannot be used. The custom start position feature seems to only allow a static start position. setChoiceValue also doesn't work because it preselects the answer as well. I need the participant to actively choose a value.
Has anybody else achieved this previously? I scoured the community, but the only answers pointed to the default choice option which does not solve my issue.

This question has been asked before here, but the answer didn't address the dynamic start position or the forcing of the response.

icon

Best answer by SurajK 26 August 2020, 01:25

View original

3 replies

Userlevel 5
Badge +4

Hi lillianc ,
There is a way to meet this requirement, set the start position using "Edit Default Choices" and add the below JS code in the slider question.
Using this code we can hide the next button until all the slider values changes from its current start position, once they change the value then the next button will appear.
Here customCnt is your dynamic start position.
Qualtrics.SurveyEngine.addOnReady(function()
{
var customCnt = "${e://Field/customCnt}"  // Dynamic value where you want start position

// Check if all the sliders have changed from start position.
jQuery(".NextButton").css('visibility','hidden')
jQuery(".ResultsInput").change(function(){
var cnt=0;
for(var i=0;i<3;i++)
{
if(jQuery('.ResultsInput').eq(i).attr("value") == customCnt)
{
jQuery(".NextButton").css('visibility','hidden')
}
else
{
cnt+=1
}
}
if(cnt == jQuery('.slider-container').length)
{
jQuery(".NextButton").css('visibility','visible')
}
});
});

Userlevel 5
Badge +7

Thanks @SurajK! This is on the right track, but the code seems to require that the respondent changes the answer value. We don't want to exclude the starting position from being their choice to continue. They should be free to choose the starting position as their answer choice, but we want them to actively make that decision.

Userlevel 5
Badge +7

I was able to modify the code to achieve what I needed it to do, thanks SurajK. The code below requires that both sliders be clicked in order for the next button to show, but does not require that the answer to have a certain value, nor does it require them to change the value.
Qualtrics.SurveyEngine.addOnReady(function()
{
    $('NextButton').hide(); 

    //this example just checks the first 2 sliders
    //both sliders have to be clicked to show the next button
    var slider1;
    var slider2;

    //check first slider
    jQuery(".track").eq(0).click(function(){
        slider1 = 1 ; 
    if (slider1 == 1 & slider2 == 1){
                $('NextButton').show(); 
    }
    });

    //check second slider
    jQuery(".track").eq(1).click(function(){
        slider2 = 1 ;
    if (slider1 == 1 & slider2 == 1){
        $('NextButton').show(); 
    }
    });
});

Leave a Reply