Transforming piped text to lowercase | XM Community
Skip to main content

Like this user, I'm piping selected choices from an initial question into a second one (after a page break) as follows:

Why do you think this study measured ${q://QID28/ChoiceGroup/SelectedChoices} intake?

Because the options given in the initial question began with uppercase characters, the second question renders as, for example:
Why do you think this study measured Fruit intake?

but I want
Why do you think this study measured fruit intake?

Per the answer to the previous user's question, I have the following JS in the second question:
Qualtrics.SurveyEngine.addOnload(function() {  jQuery("span.lowercase").html("${q://QID28/ChoiceGroup/SelectedChoices}".toLowerCase()); });

and the following HTML:
Why do you think this study measured ${q://QID28/ChoiceGroup/SelectedChoices} intake?

but the piped text is still not lowercase.
Based on this other related question, I also tried adding the following to the custom CSS in the survey's Look & Feel:
span.lowercase { text-transform: lowercase; }
and this also did not work. Any suggestions?

Not sure why what you tried didn't work, but the easiest solution is:
${q://QID28/ChoiceGroup/SelectedChoices}


Beautiful! Worked perfectly. Thanks, Tom.


How would you lowercase the first letter, but not the rest of the piped text? I have proper names in the middle of the answer choices piped in and I don't want them lowercased, just the first letter.


https://www.qualtrics.com/community/discussion/comment/30990#Comment_30990You would have to do that with JavaScript.


Hiya, I'm also trying to change the first letter of piped text to lowercase - I've tried inserting the following javascript (not a coder!) after some googling around but it doesn't seem to work. Does anyone have any ideas/recommendations on how to do this?
Qualtrics.SurveyEngine.addOnload(function()
{
let s = "${q://QID2/ChoiceDescription/1}"
let lowerCaseFirst = s.charAt(0).toLowerCase() + s.slice(1)

});
Any help would be greatly appreciated. Thanks!


https://www.qualtrics.com/community/discussion/comment/33545#Comment_33545You need to update the html. Do this:
HTML:
${q://QID2/ChoiceDescription/1}
JS:
var myPipe = jQuery("#"+this.questionId+" .myPipe");
var s = myPipe.text();
myPipe.text(s.charAt(0).toLowerCase() + s.slice(1));


Thank you very much sir!


Leave a Reply