Amending slider question scale? | XM Community
Skip to main content

Has any cracked the code to modify the slider scale to dollars? I'm hoping to modify to $0 to $100,000.
Any ideas?
Chipper 🧐

Hi Chipper ,
You can add below code to your slider question to add "$" before amount :
Qualtrics.SurveyEngine.addOnload(function()
{/*Place your JavaScript here to run when the page loads*/
});
Qualtrics.SurveyEngine.addOnReady(function()
{
const numbers = document.querySelectorAll(".numbers li");


numbers.forEach(function(li) {
  const num = li.textContent.trim();
  li.textContent =  "$"+ num;
});
});
Qualtrics.SurveyEngine.addOnUnload(function()
{/*Place your JavaScript here to run when the page is unloaded*/
});
Hope it resolved your query.😊!!!


Awesome, Qualtrics Nerd! From searching previous questions, it seems you've solved a several-years long quest!!
If you have advice on inserting a comment to denote thousands, e.g., $20,000 and wouldn't mind sharing that, I'd be grateful.
Thanks again!
Chipper


Hi Chipper ,
I think you meant to add commas after thousand and so on like 1,12,000.
You can replace above code with below :
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/


});


Qualtrics.SurveyEngine.addOnReady(function()
{
const numbers = document.querySelectorAll(".numbers li");


numbers.forEach(function(li) {
  const num = li.textContent.trim();
  const formattedNum = Number(num).toLocaleString('en-IN');
  li.textContent =  "$" + formattedNum;
});




});


Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/


});
Hope it resolved your query😊!!!


Of course, "Locale String!" Thank you for the second response and help.


Hi @qualtrics_nerd

Do you know the code for commas like this: $1,000,000,000? When I tried your above code it comes out to looking like: $1,00,00,00,000
Thank you in advance!


Hi @andrea g ,
Yes, you can achieve that by updating the parameter inside localeString(‘en-IN’) to  localeString(‘en-US’) , Below is the updated code:
 

Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/

});

Qualtrics.SurveyEngine.addOnReady(function()
{
const numbers = document.querySelectorAll(".numbers li");


numbers.forEach(function(li) {
const num = li.textContent.trim();
const formattedNum = Number(num).toLocaleString('en-US');
li.textContent = "$" + formattedNum;
});




});

Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/

});

Hope this resolves your query😊!!!


Leave a Reply