0 votes
in SoSci Survey (English) by s309575 (155 points)
edited by s309575

My question is about age - I want participants to use a slider to indicate an age between 0 and 100. However, the slider seems built for percentages. How can I make it so that the chosen value that is displayed at the top is not a percentage?

by s109993 (12.6k points)
Just out of curiosity: Why do you not use a text field to ask for the age of your participants? Regarding you question: I can not find any percentage indicator- could you maybe post a screenshot what bothers you?
by s309575 (155 points)
I chose a slider because I wanted to constrain respondents' answers so that they enter only numeric values between 0 and 100. Attached is a screenshot!

1 Answer

0 votes
by SoSci Survey (347k points)

You'll need a few lines of JavaScript, see Slider -> Display the Current Position.

This script, by and large, converts the actual numeric value into what the questionnaire should display.

by s309575 (155 points)
That's good to know - thank you. The manual doesn't describe how to display an absolute value. When I use the "Basis-Script" code, the slider turns into a multiple choice question. The only other options in the manual are to change the format of the displayed value to take the form of time, percentages, Euros, and negative values.
by SoSci Survey (347k points)
>  When I use the "Basis-Script" code, the slider turns into a multiple choice question.

That usually happens when there is an error in the code that stops other code on the page (the one that creates the slider) from running.

>  The only other options in the manual are to change the format of the displayed value to take the form of time, percentages, Euros, and negative values.

I would apprechiate if you tried to understand what these few lines of code do. It will be worth the time. However, here's the reduced version that just does not display a % sign.

var formatter = function(value, reversed) {
  if (value < 0) return "";
  return String(Math.round(value - 1));
}
SoSciSliders.setFormat(formatter);
by s309575 (155 points)
Thank you very much for your help. Do you know how I can change this so that the displayed value aligns with the values on the slider? Specifically, my slider question asks respondents to select a value between 18 and 99. The code you sent me worked but displays values from 1-100.
by SoSci Survey (347k points)
The range from 18 to 99 has (99-18)+1 = 82 different values. Therefore set the differentiation of the slider to 1..82. These are the values you'll have in the dataset.

Now add 17 to the value in the display ...

var formatter = function(value, reversed) {
  if (value < 0) return "";
  return String(Math.round(value +17));
}
SoSciSliders.setFormat(formatter);


... and - eventually - in your dataset for the analysis. Here's an example for PHP code working with an internal variable IV01_01.

put('IV01_01', value('SL01_01') + 17);
by s309575 (155 points)
Thank you so much!

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...