Formatting embedded data to make it all lowercase | XM Community
Solved

Formatting embedded data to make it all lowercase

  • 21 March 2019
  • 6 replies
  • 274 views

Badge +1
Hello,

I created embedded data based on the answer to the multiple-choice question. Let's say the question looks like this:

Which color is your favorite?
1. Red
2. Blue
3. Green

And I recorded the answer as "color".

Then, I want to use "color" in the survey like:

You choose ${e://Field/color} color for your favorite.

Currently, the result looks like: "You choose Green color for your favorite."

But I want to change the format of "Green" to "green", making all characters lowercase.

Is it possible to do it?

Thank you very much in advance.
icon

Best answer by TomG 22 March 2019, 00:33

View original

6 replies

Userlevel 7
Badge +27
Use JavaScript:
```
"${e://Field/color}".toLowerCase();
```
Badge +1
@TomG,
Thanks for your answer. Do you mean using Java, like as follows on the page that I used the embedded data?

Qualtrics.SurveyEngine.addOnload(function()
{
"${e://Field/color}".toLowerCase();
});
Userlevel 7
Badge +27
> @jhwang said:
> @TomG,
> Thanks for your answer. Do you mean using Java, like as follows on the page that I used the embedded data?
>
> Qualtrics.SurveyEngine.addOnload(function()
> {
> "${e://Field/color}".toLowerCase();
> });

That's JavaScript (Java is a different language that isn't used in Qualtrics). You've got the basic idea, but the script isn't correct. The specific script would depend on what question you are attaching the script to. Let's say it is the question where you want to pipe color, and your question html is:
```
You choose <span class="color"></span> color for your favorite.
```
Then your JS would be:
```
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("span.color").html("${e://Field/color}".toLowerCase());
});
```
Badge +1
@TomG,
Thank you for the clarification. Now I use this html for my question:

`You choose <span class="color">${e://Field/color}</span>.`

And JS is like:
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("span.color").html("${e://Field/color}".toLowerCase());
});

And the result is:
You choose green.

But if I want to make "green" bold, like:
You choose green.

Is it possible to set two styles (lowercase and bold)?
Userlevel 7
Badge +27
> @jhwang said:
> @TomG,
> Thank you for the clarification. Now I use this html for my question:
>
> `You choose <span class="color">${e://Field/color}</span>.`
>
> And JS is like:
> Qualtrics.SurveyEngine.addOnload(function() {
> jQuery("span.color").html("${e://Field/color}".toLowerCase());
> });
>
> And the result is:
> You choose green.
>
> But if I want to make "green" bold, like:
> You choose green.
>
> Is it possible to set two styles (lowercase and bold)?

Change the style of the span:
```
<span class="color" style="font-weight:bold">${e://Field/color}</span>
```
Badge +1
@TomG,
Great!
It works perfectly. Thank you very much for your help!

Leave a Reply