Change Slider Question Values | XM Community
Solved

Change Slider Question Values

  • 9 October 2019
  • 6 replies
  • 145 views

Badge
Hi,

Currently working on a survey in which I'm using the slider question and I want the slider to start at 1 and go to 100 with the grid line values being at 10, 20, 30,...,90, 100. At present, I have the settings as follows:
Min value: 1
Max value: 100
Grid lines: 10
and the question looks like this
!

Is there anything I can do (js code? question settings?) to change the grid line values to match what I need them to be at (10, 20, 30, .... ,90, 100)?
icon

Best answer by fleb 10 October 2019, 19:50

View original

6 replies

Userlevel 5
Badge +15
Hi @KS28 , is there a reason you don't want it to start at 0? That would fix this issue.
Badge
Hi @ClairJ ! Thanks for your response! So I didn't want to start at 0 because in my previous question I ask if they want to put some percent of the refund into their account and they only see the slider question if they say yes to the previous question so there is an implicit assumption that they will put at least 1 percent
Userlevel 5
Badge +6
Hi @KS28 ,
you can access any element using CSS selectors and modify its HTML content.
Try the following code:

Qualtrics.SurveyEngine.addOnload(function()
{
var myCSS = "#" + this.questionId + " .q-slider .horizontalbar .numbers li";
var n = jQuery(myCSS).length;

var JQ, i, val;

for (i = 1; i < n; i++)
{
JQ = jQuery(myCSS + ":nth-of-type("+i+")");
val = Number(JQ.html());

JQ.html(val + 1);
}
});
Badge
@fleb Thank you! The code was very helpful!
Userlevel 5
Badge +15
@KS28 got it...glad you found a solution!
@fleb Doesn't this only change the displayed text? Is there a way to actually change the value?

Leave a Reply