Change Slider Question Values | XM Community
Skip to main content
Solved

Change Slider Question Values

  • October 9, 2019
  • 6 replies
  • 233 views

Forum|alt.badge.img
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)?

Best answer by fleb

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); } });

6 replies

ClairJ
Level 4 ●●●●
Forum|alt.badge.img+15
  • Level 4 ●●●●
  • October 9, 2019
Hi @KS28 , is there a reason you don't want it to start at 0? That would fix this issue.

Forum|alt.badge.img
  • Author
  • October 9, 2019
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

fleb
Level 3 ●●●
Forum|alt.badge.img+6
  • Level 3 ●●●
  • Answer
  • October 10, 2019
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); } });

Forum|alt.badge.img
  • Author
  • October 10, 2019
@fleb Thank you! The code was very helpful!

ClairJ
Level 4 ●●●●
Forum|alt.badge.img+15
  • Level 4 ●●●●
  • October 10, 2019
@KS28 got it...glad you found a solution!

  • October 11, 2019
@fleb Doesn't this only change the displayed text? Is there a way to actually change the value?