0 votes
ago in SoSci Survey (English) by s127710 (130 points)
edited ago by SoSci Survey

Hello SoSci team,

I am using sliders in my study to examine, for example, how unattractive or attractive a face is. AT the moment present the slider with the center starting at 50% and then increasing up to 100% on both directions. For that I use the html code below:


! <script type="text/javascript">
<!--
var formatter = function(value) {
  if (value < 0) return "";
  if (value < 50) {
   value = (102-value);
      
   }
value = Math.round(value-1);
 return  value + "%"; 
}
SoSciSliders.setFormat(formatter);
  
// -->
</script>

My question is, how can adjust this code so that the starting point in the center is set to 0 (not 50) with increases of up to 100 on both directions?

Thank you for your help!
Best

1 Answer

0 votes
ago by SoSci Survey (328k points)

By and large, you decrease by 51 and multiply by 2.

var formatter = function(value) {
   if (value < 0) return "";
   value = Math.abs(Math.round((value - 51) * 2));
   return  value + "%"; 
}

Math.abs() will remove the minus.

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

...