Changing first letter of piped text to lowercase | XM Community
Skip to main content

I want to pipe the selection from a standard likert scale question like the one below into a follow-up open ended question.

  1. Very unlikely
  2. Somewhat unlikely
  3. Neither likely nor unlikely
  4. Somewhat likely
  5. Very likely

I want to change the first letter of the piped selection so that it is lower case.

The piping instruction I currently have in the open ended question is:
Why are you ${q://QID26/ChoiceGroup/SelectedChoices} to consider using... 

I tried using the tips noted in the thread below but it isn’t working for me.

 

I think the html was lost from that post when the Community platform changed.

Use this html in your question text:

Why are you <span style="text-transform:lowercase">${q://QID26/ChoiceGroup/SelectedChoices}</span> to consider using... 

 


Is it possible to do this for all answer options except one? I have the list below and would like to pipe the selection into the middle of the subsequent question text. The lowercase transformation would apply to all options except the brand name which should stay capitalized.

  1. A plumber
  2. A contractor
  3. A water cleanup/drying service
  4. [BRAND]
  5. My insurance agent
  6. A friend or family member

Can I do this with html or do I need to set embed data to pipe instead?


@Regan,

In your MC question, put [BRAND] inside a span with capitalize:

<span style='text-transform:capitalize'>[BRAND]</span>

When piped this span’s style will take precedence over the span with the lowercase style.


Thanks, ​@TomG, this worked perfectly! I have a follow-up for the same question…

Answer choice 5 below doesn’t make sense when piped into the following question. To make sense the next needs to be “your insurance agent” when piped.

 

Q1  Which of the following best describes who you would contact first?

  1. A plumber
  2. A contractor
  3. A water cleanup/drying service
  4. [BRAND]
  5. My insurance agent OK HERE
  6. A friend or family member

 

Q2  Why would you contact ${q://QID9/ChoiceGroup/SelectedChoicesTextEntry} first? DOESN’T MAKE SENSE HERE; NEEDS TO BE “your insurance agent”

 

Is there a way to modify just this entry with JS and/or HTML? I would love to avoid creating embedded data fields since all the other options are working so well with tips you already provided.


Make the choice in Q1:

<span class="your">your</span> insurance agent

Add this JS to Q1:

Qualtrics.SurveyEngine.addOnload(function() {
this.getQuestionContainer().querySelector(".your").innerText = "My";
});

 


Thank you SO much!


What happens when the answer option has multiple uppercase characters and I only want to make the first letter lowercase? For example, ‘An IBM computer’ should be ‘an IBM computer’.  


What happens when the answer option has multiple uppercase characters and I only want to make the first letter lowercase? For example, ‘An IBM computer’ should be ‘an IBM computer’.  

See my answer to ​@Regan’s question above. Put the ‘a’ in a span and change it to ‘A’ in the first question.

 


What happens when the answer option has multiple uppercase characters and I only want to make the first letter lowercase? For example, ‘An IBM computer’ should be ‘an IBM computer’.  

See my answer to ​@Regan’s question above. Put the ‘a’ in a span and change it to ‘A’ in the first question.

 

Thanks. So if the first letter of the first word changes to any other letter, it would be a different span? 


What happens when the answer option has multiple uppercase characters and I only want to make the first letter lowercase? For example, ‘An IBM computer’ should be ‘an IBM computer’.  

See my answer to ​@Regan’s question above. Put the ‘a’ in a span and change it to ‘A’ in the first question.

 

Thanks. So if the first letter of the first word changes to any other letter, it would be a different span? 

Difference spans yes, but they can all have the same class. Then have the JS change each occurrence to upper case. The JS would be slightly different:

Qualtrics.SurveyEngine.addOnload(function() {
this.getQuestionContainer().querySelectorAll(".fl").forEach(function(el) {
el.innerText = el.innerText.toUpperCase();
});
});

 


What happens when the answer option has multiple uppercase characters and I only want to make the first letter lowercase? For example, ‘An IBM computer’ should be ‘an IBM computer’.  

See my answer to ​@Regan’s question above. Put the ‘a’ in a span and change it to ‘A’ in the first question.

 

Thanks. So if the first letter of the first word changes to any other letter, it would be a different span? 

Difference spans yes, but they can all have the same class. Then have the JS change each occurrence to upper case. The JS would be slightly different:

Qualtrics.SurveyEngine.addOnload(function() {
this.getQuestionContainer().querySelectorAll(".fl").forEach(function(el) {
el.innerText = el.innerText.toUpperCase();
});
});

 

Thanks!