Change Slider Question Values

KS28KS28 DurhamCommunity Member Qubie ✭

Change Slider Question Values


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

  • flebfleb Czech Republic Sage ✭✭✭
    Accepted Answer

    Hi @KS28 ,
    you can access any element using CSS selectors and modify its HTML content.
    Try the following code:

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


  • ClairJClairJ Philadelphia, PACommunity Member Guru ✭✭

    Hi @KS28 , is there a reason you don't want it to start at 0? That would fix this issue.

  • KS28KS28 DurhamCommunity Member Qubie ✭
    edited October 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

  • KS28KS28 DurhamCommunity Member Qubie ✭

    @fleb Thank you! The code was very helpful!

  • ClairJClairJ Philadelphia, PACommunity Member Guru ✭✭

    @KS28 got it...glad you found a solution!

  • SprongSprong Madison, WICommunity Member Qubie ✭

    @fleb Doesn't this only change the displayed text? Is there a way to actually change the value?

Sign In to Comment