Solved
Formatting Embedded Data with comma separators?
Hello,
There is an embedded data that I am outputting in a Text/Graphic box and in the question. For ease of reading, I would like to format this as a currency - or at the very least with thousand comma separators.
What would be the best way of handling this? I've looked around and couldn't find any code samples on this (most of the code samples involved formatting input fields, not embedded data).
There is an embedded data that I am outputting in a Text/Graphic box and in the question. For ease of reading, I would like to format this as a currency - or at the very least with thousand comma separators.
What would be the best way of handling this? I've looked around and couldn't find any code samples on this (most of the code samples involved formatting input fields, not embedded data).
Best answer by TomG
In html, create a span with an id that will contain the formatted number:
```
<span id="mynumber">mynumber</span>
```
Use JS to format the number and replace the span contents:
```
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#mynumber").text("$"+parseFloat("${e://Field/mynumber}").toFixed(2).toLocaleString());
});
```
View original```
<span id="mynumber">mynumber</span>
```
Use JS to format the number and replace the span contents:
```
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#mynumber").text("$"+parseFloat("${e://Field/mynumber}").toFixed(2).toLocaleString());
});
```
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.