Javascript on slider values (% symbol) | XM Community
Solved

Javascript on slider values (% symbol)

  • 4 June 2018
  • 3 replies
  • 166 views

Badge
Is there a way to use javascript insert a percent symbol (%) after the values in a slider question?

So instead of the values reading 0, 10, 20, 30 etc on the example below, it would read 10%, 20%, 30%

!


Thank you!
Melissa
icon

Best answer by Rich_Boits_Walker 6 June 2018, 05:57

View original

3 replies

Userlevel 5
Badge +7
Hey @Melissa_E,
There is a css trick to get this done with the content property and the :after element. Go to the HTML view tab to the right of the edit box in the question editor and add the following script above your question text.

<style>
ul.numbers li::after {
content:"%";
}
</style>

Need to give a warning when using this however. The format of the generated html in the survey leaves white space after the content and the closing li tags... so this can/will cause wrapping issues on mobile.

If that's a concern you may need to look into looping over the li elements in the javascript editor and using the jquery $.trim(str) function.
Badge
This is perfect! Thank you SO much 😶 😶 😶
Badge

Is there a way to add the % sign over the number on the actual slider?

Leave a Reply