Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Slider - Reset button

  • TrbSpirit
  • TrbSpirit's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 months 1 week ago #243566 by TrbSpirit
Slider - Reset button was created by TrbSpirit
Hello,

I have issues with the reset button. I want to assign the value 0 only when the reset button is clicked. In any other situation, i want an empty value. I know Limesurvey support that feature, but it doesn’t seam to work.

You will fin the necessary file to operate the survey.

Thank you.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 months 1 week ago - 11 months 1 week ago #243568 by Joffm
Replied by Joffm on topic Slider - Reset button
So you really want to get a value of "0 = fully disagree" if the respondent resets the button = "I don't know / I don't want to answer"?
I do not understand this.

I think it is implemented correct.
Unless the respondent moves the handle (or resets the slider) the value is "empty".
If he moves the handle the value is stored, even if the respondent moves the handle to "0".

Joffm

And, please answer the questions at the beginning. And DO NOT remove them.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 11 months 1 week ago by Joffm.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 months 1 week ago - 11 months 1 week ago #243571 by tpartner
Replied by tpartner on topic Slider - Reset button
My thinking is that if the slider initial value (slider_default) is set, clicking the reset button shoud revert to (and store) that value. If no default value is set, the reset button should store null.

- manual.limesurvey.org/Question_type_-_Mu....28slider_default.29

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 11 months 1 week ago by tpartner.

Please Log in to join the conversation.

  • TrbSpirit
  • TrbSpirit's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 months 1 week ago #243584 by TrbSpirit
Replied by TrbSpirit on topic Slider - Reset button
I want 0 = "I don't know / I don't want to answer"
1 thru 10 are the answer of the slider

The value 0 dosent store when the reset buton is press. Its set to empty

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 months 1 week ago - 11 months 1 week ago #243587 by Joffm
Replied by Joffm on topic Slider - Reset button
Yes, there is no "Don't know" in a slider question.
Either you leave it empty or there is a value.

And you set the scale from "0" to "10".
So "0" is a valid value, which the respondent can select
And furthermore: You try to misuse the "reset" button.
"Reset" means "Set back to the initial valies" not more, not less..

But there is an easy workaround.
In an following equation set the value of an empty slider to "0".
{Q1_a=if(is_empty(Q1_a),0,Q1_a)}
...





Joffm

Or you may revise your question. Use an array.

Or you may use "tick marks". There are some examples in the forum.
Just an example: Read the red smiley as "DK/NA" and show an appropriate value under the scale 
 

I found a thread about it.
[url] forums.limesurvey.org/index.php/forum/ge...icht?start=12#216557 [/url]

A last word about it.

Could be like this
 

or like this
 

or maybe something else.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 11 months 1 week ago by Joffm.
The following user(s) said Thank You: DenisChenu, tpartner

Please Log in to join the conversation.

  • TrbSpirit
  • TrbSpirit's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 months 6 days ago #243610 by TrbSpirit
Replied by TrbSpirit on topic Slider - Reset button
Thank you for your help! I would like to use the "tick marks". I like the first picture you share. Howevwer I decided to change the value 11 =  not applicable (NAP). I look in the link, copy/paste and modify the code. I have difficulty to understand it. I'll attached what i worked so far. Here is my code :

<strong><span style="font-size:11.0pt"><span style="font-family:&quot;Calibri&quot;,sans-serif">Quelles sont les raisons qui t'ont amené à t’inscrire pour cette expérience de stage en dehors de la région?</span></span></strong> <strong><span style="font-size:11.0pt"><span style="font-family:&quot;Calibri&quot;,sans-serif">Quelles sont les raisons qui t'ont amené à t’inscrire pour cette expérience de stage en dehors de la région?</span></span></strong> <script type="text/javascript" charset="utf-8">
 
    $(document).on('ready pjax:scriptcomplete',function(){
 
        // Identify this question
        var thisQuestion = $('#question{QID}');
 
        // Define the text strings
        var tipTexts = {
            1:    '1',
            2:    '2',
            3:    '3',
            4:    '4',
            5:    '5',
            6:    '6,
            7:    '7',
            8:    '8',
            9:    '9',
            10:   '10',
            11:   'NAP'
        };
      };
 
        $('input:text', thisQuestion).on('slideEnabled',function(){ 
            var thisItem = $(this).closest('li');
 
            // Insert custom tooltip
            $('.tooltip-inner', thisItem).addClass('tooltip-inner-1 hidden');
            var i0=$(this).val();
            i0=Number(i0)+1;
 
            $('.tooltip', thisItem).append('<div class="tooltip-inner tooltip-inner-2">'+tipTexts[i0]+'</div>');
 
          // Listener on slider
            $(this).on('slide slideStop', function(event) {
                // Handle dynamic tooltip text
              var i1=$(this).val();
              i1=Number(i1)+1;
                $('.tooltip-inner-2', thisItem).html(tipTexts[i1]);
 
            });
 
        });
    });
</script> <script type="text/javascript" charset="utf-8">
    $(document).on('ready pjax:scriptcomplete',function(){
 
        var ticksArray = [
            [1, '          1'],
            [10, '10'],
        ];
        var ticksArray2 = [
          [+11, 'NAP'],
          ];
 
        insertSliderTicks('{QID}', ticksArray);
        insertSliderTicks2('{QID}', ticksArray2);
    });
 
/* Insert Slider Tick Marks */
    function insertSliderTicks(qID, ticksArray) {
        var thisQuestion = $('#question'+qID);
 
        $(thisQuestion).addClass('with-inserted-ticks');
 
        $('input:text', thisQuestion).on('slideEnabled',function(){ 
            var thisSlider = $(this);
            var thisItem = $(thisSlider).closest('li');
            var thisMin = $('.slider-handle:eq(0)', thisItem).attr('aria-valuemin');
            var thisMax = $('.slider-handle:eq(0)', thisItem).attr('aria-valuemax');
            var thisRange = thisMax - thisMin;
            $.each(ticksArray, function(i, val) {
                var tickRelativePosition = val[0] - thisMin;
                var tickPercent = (tickRelativePosition/thisRange)*100;
 
                // Insert tick marks
                $('.slider-handle:eq(0)', thisItem).before('<div class="inserted-tick left-'+tickPercent+'" style="left: '+tickPercent+'%">\
                                                    <div class="tick-text">'+val[1]+'</div>\
                                                </div>');
            });    
        });
    }
    /* Insert Slider Tick Marks */
    function insertSliderTicks2(qID, ticksArray2) {
        var thisQuestion = $('#question'+qID);
 
        $(thisQuestion).addClass('with-inserted-ticks');
 
        $('input:text', thisQuestion).on('slideEnabled',function(){ 
            var thisSlider = $(this);
            var thisItem = $(thisSlider).closest('li');
            var thisMin = $('.slider-handle:eq(0)', thisItem).attr('aria-valuemin');
            var thisMax = $('.slider-handle:eq(0)', thisItem).attr('aria-valuemax');
            var thisRange = thisMax - thisMin;
            $.each(ticksArray2, function(i, val) {
                var tickRelativePosition = val[0] - thisMin;
                var tickPercent = (tickRelativePosition/thisRange)*100;
 
                // Insert tick marks
                $('.slider-handle:eq(0)', thisItem).before('<div class="inserted-tick2 left-'+tickPercent+'" style="left: '+tickPercent+'%">\
                                                    <div class="tick-text">'+val[1]+'</div>\
                                                </div>');
            });    
        });
    }
</script>
<style type="text/css">/* Slider Tick Marks */
 
    @media only screen and (min-width: 768px) {
 
        .with-inserted-ticks .slider-container {
            padding-right: 30px;
            padding-left: 30px;
        }
    }
 
    .with-inserted-ticks .slider-item {
        margin-bottom: 50px;
    }
 
    .with-inserted-ticks .slider-container .help-block {
        margin: 25px 0 0 -25px;
        width: 40px;
        text-align: center;
    }
 
    .with-inserted-ticks .slider-container .help-block.pull-right {
        margin: 25px -20px 0 0;
    }
 
    .inserted-tick, .inserted-tick2 {
        position: absolute;
        top: 50%;
        height: 20px;
        width: 4px;
        margin-top: -5px;
        margin-left: -1px;
        background-color: #DDDDDD; 
        background-color: black; 
    }
 
    .inserted-tick2.left-0,
    .inserted-tick2.left-100,
    .inserted-tick.left-0,
    .inserted-tick.left-100 {
        background-color: transparent;
        background-color: black; 
    }
 
    .inserted-tick2 .tick-text {
        position: absolute;
        top: -250%;
        width: 100px;
        margin-left: -50px;
        color: #000000;
        text-align: center; 
    }
    .inserted-tick .tick-text {
        position: absolute;
        top: 150%;
        width: 100px;
        margin-left: -20px;
        color: #000000;
        text-align: center; 
    }
 
 
        .inserted-tick.left-0 .tick-text {
            margin-left: 0px;
            text-align: left; 
        }
 
        .inserted-tick.left-100 .tick-text {
            margin-left: -100px;
            text-align: right; 
        }
 
    }
</style>
 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 months 6 days ago #243613 by Joffm
Replied by Joffm on topic Slider - Reset button
No, no, 
I won't create a survey, a group, a question and then copy/paste your script.

Please, provide the lss export of this question.

Joffm 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

  • TrbSpirit
  • TrbSpirit's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 months 6 days ago #243616 by TrbSpirit
Replied by TrbSpirit on topic Slider - Reset button
Sorry.

Here it is. Thank you again

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 months 5 days ago #243623 by Joffm
Replied by Joffm on topic Slider - Reset button
So, what is your concern?
The misalignment of "10"?

Here I removed the second scale, though it is still included in the css part.
 

 

File Attachment:

File Name: limesurvey...3626.lss
File Size:42 KB


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu, tpartner, Helenahh

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 months 3 days ago #243681 by DenisChenu
Replied by DenisChenu on topic Slider - Reset button
@Joffm : i ,need your email to hire you sometime …

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.

Please Log in to join the conversation.

  • TrbSpirit
  • TrbSpirit's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 months 2 days ago #243702 by TrbSpirit
Replied by TrbSpirit on topic Slider - Reset button
Thank you very much for your time and effort! This is exactly what I'm looking for!

Have a nice day!

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 months 16 hours ago #243775 by Joffm
Replied by Joffm on topic Slider - Reset button

 i ,need your email to hire you sometime …

@Denis, you forgot three things:
1. The smiley 
2. My age, see my profile
3. 99% of the javascript solutions I show here are based on @Tony's scripts. My knowledge of javascript is very, very limited.

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose