Transforming piped text to lowercase | XM Community
Solved

Transforming piped text to lowercase

  • 20 August 2020
  • 7 replies
  • 711 views

Badge +2

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?

icon

Best answer by TomG 20 August 2020, 16:20

View original

7 replies

Userlevel 7
Badge +27

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

Badge +2

Beautiful! Worked perfectly. Thanks, Tom.

Badge +1

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.

Userlevel 7
Badge +27

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

Badge +3

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!

Userlevel 7
Badge +27

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));

Badge +3

Thank you very much sir!

Leave a Reply