Formatting values on constant sum slider as $USD | XM Community
Solved

Formatting values on constant sum slider as $USD

  • 25 January 2024
  • 1 reply
  • 57 views

Badge +1

Hi all,

 

I’m using a constant sum slider for a funding distribution task. I’d like to show the slider values in $USD format — so the constant sum slider would range from $0 to $50,000, for example. Does anyone know if this can be done using Javascript or CSS? My question is very similar to this one, but I can’t figure out how to adapt the code for a constant sum slider: 

Many thanks!

icon

Best answer by Shashi 26 January 2024, 01:20

View original

1 reply

Userlevel 6
Badge +27

We cannot put any character in constant sum text box other than number, hence we cannot add ‘$’ in text box.If you are asking to change the number format above slider then it can be done using below JS:

jQuery(".TickContainer:eq(1) .MinValue").text("$0");
jQuery(".TickContainer:eq(1) span:eq(1)").text("$5,000");
jQuery(".TickContainer:eq(2) span:eq(0)").text("$10,000");
jQuery(".TickContainer:eq(3) span:eq(0)").text("$10,000");
.
.
.
jQuery(".TickContainer:eq(10) span:eq(0)").text("$10,000");

But adding extra characters will disturb the alignment of the labels, so make sure to have very few labels.

Leave a Reply