Javascript on slider values (% symbol) | XM Community
Skip to main content
Solved

Javascript on slider values (% symbol)

  • June 4, 2018
  • 3 replies
  • 248 views

Forum|alt.badge.img
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

Best answer by Rich_Boits_Walker

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.

3 replies

Rich_Boits_Walker
QPN Level 3 ●●●
Forum|alt.badge.img+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.

Forum|alt.badge.img
  • Author
  • June 6, 2018
This is perfect! Thank you SO much :# :# :#

Forum|alt.badge.img
  • July 7, 2022

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