How to add % to the numbers in a slider question | XM Community
Solved

How to add % to the numbers in a slider question

  • 3 August 2020
  • 9 replies
  • 451 views

Hi, I have a slider question in my survey where I want the respondent to give a threshold as an answer, but what is shown on the slider is just numbers from 0 to 100. I wanted to know if it's possible to add % after at least 0 and 100.

icon

Best answer by rondev 6 August 2020, 20:54

View original

9 replies

Userlevel 5
Badge +4

Try the below code,
jQuery('#'+this.questionId+' .numbers').find('li').append('%')

Thank you, it worked. The only problem now is that there isn't enough space for 100% so % is shown below 100.
Capture.JPG

Userlevel 7
Badge +22

Try the below code:
jQuery("#"+this.questionId+" .numbers li").each(function(){

jQuery(this).text((jQuery(this).text()+"%").trim().replace(" ",""));

});

Thank you, it was great!

Hi, I just noticed that in the mobile view the numbers are very cramped now. Is it possible to limit the percent sign only to the first and last numbers?

Userlevel 7
Badge +22

https://www.qualtrics.com/community/discussion/comment/28985#Comment_28985Use this code:
jQuery("#"+this.questionId+" .first").text((jQuery("#"+this.questionId+" .first").text()+"%").trim().replace(" ",""));
jQuery("#"+this.questionId+" .last").text((jQuery("#"+this.questionId+" .last").text()+"%").trim().replace(" ",""));

I'm sorry, but could you also give me a code which puts % just for 100. I mean I don't want other numbers to have percentage sign.

Userlevel 7
Badge +22

https://www.qualtrics.com/community/discussion/comment/29377#Comment_29377jQuery("#"+this.questionId+" .last").text((jQuery("#"+this.questionId+" .last").text()+"%").trim().replace(" ",""));

Badge

This code: jQuery("#"+this.questionId+" .numbers li").each(function(){

jQuery(this).text((jQuery(this).text()+"%").trim().replace(" ",""));

});
produces 2 times the '%' symbol (example: 0%%). How can I delete one?

Leave a Reply