How to add percent signs after multiple text entries | XM Community
Skip to main content
Question

How to add percent signs after multiple text entries

  • February 27, 2020
  • 8 replies
  • 262 views

Forum|alt.badge.img+1
Hi, I'm looking for some advice regarding adding percent signs after multiple text entries. I have been using JS (see code below) but have been adding a percent sign after the text entry box after the "Other" option. Is there a way to avoid this? !

8 replies

npetrov937
Level 2 ●●
Forum|alt.badge.img+4
  • Level 2 ●●
  • 124 replies
  • February 28, 2020
Maybe it's just me, but I can't see any code?

Forum|alt.badge.img+1
  • Author
  • 7 replies
  • February 28, 2020
Sorry! I've been using the following code: var questionId = this.questionId; var choiceInputs = $$('#'+this.questionId + ' .ChoiceStructure input'); for (var i=0; i < choiceInputs.length; i++) {var choiceInput = choiceInputs[i]; try {if (choiceInput && choiceInput.parentNode) {choiceInput.parentNode.appendChild(QBuilder('span',{},'%')); } } catch(e) { } }

npetrov937
Level 2 ●●
Forum|alt.badge.img+4
  • Level 2 ●●
  • 124 replies
  • February 28, 2020
Hi, You did not clarify what the type of question was. I tried replicating by what looked similar to me (there are a few ways to get to that layout) - used Side by Side. Your updated code below (I added one conditional statement and got rid of the try and catch statements as they are not useful here). .QSF attached. Qualtrics.SurveyEngine.addOnload(function() { var questionId = this.questionId; var choiceInputs = $$('#'+this.questionId + ' .ChoiceStructure input'); for (var i=0; i < choiceInputs.length; i++) { var choiceInput = choiceInputs[i]; if (choiceInput && choiceInput.parentNode && !choiceInput.className.includes("TextEntryBox")) { choiceInput.parentNode.appendChild(QBuilder('span',{},'%')); } } });

MikeW
Level 5 ●●●●●
Forum|alt.badge.img+14
  • Level 5 ●●●●●
  • 137 replies
  • September 4, 2020


https://www.qualtrics.com/community/discussion/comment/22669#Comment_22669Hi - I'm trying to do something similar... but I just want to add percentage signs after the text boxes in ONLY the second column of my side-by-side question. I don't have any other specify questions to worry about.
I've tried:
jQuery("#"+this.questionId+" .InputText").after("%");
but I only want to do the second column in my side-by-side table.



TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5937 replies
  • September 4, 2020

https://www.qualtrics.com/community/discussion/comment/29968#Comment_29968jQuery("#"+this.questionId+" .SBS2 .InputText").after("%");


MikeW
Level 5 ●●●●●
Forum|alt.badge.img+14
  • Level 5 ●●●●●
  • 137 replies
  • September 5, 2020

https://www.qualtrics.com/community/discussion/comment/29971#Comment_29971Thanks Tom - I'd previously tried...
jQuery("#"+this.questionId+" .SBS2.InputText").after("%");
...which didn't work, so I guess that space after SBS2 is important 🙂


Forum|alt.badge.img
  • Level 1 ●
  • 5 replies
  • August 4, 2023

@TomG The below code works for whole column, but i need for any one option in a column. Please give me a solution as i am new to scripting.

 #"+this.questionId+" .SBS2 .InputText").after("%");

 


rgupta15
Level 4 ●●●●
Forum|alt.badge.img+8
  • Level 4 ●●●●
  • 92 replies
  • August 10, 2023

Add a span after the choice you want the % sign and then use 

 #"+this.questionId+" .SBS2 .InputText .spanClass").after("%");


Leave a Reply