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?
!
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)
{
}
}
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',{},'%'));
}
}
});
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.
https://www.qualtrics.com/community/discussion/comment/29968#Comment_29968jQuery("#"+this.questionId+" .SBS2 .InputText").after("%");
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
#"+this.questionId+" .SBS2 .InputText").after("%");
Add a span after the choice you want the % sign and then use
#"+this.questionId+" .SBS2 .InputText .spanClass").after("%");
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.