Solved
Calculating Totals with Math Operations
I am calculating a total using math operations and storing a 6 or 7 digit number as embedded data. I want to display this to the respondent using piped text before they submit their survey. How can I add in commas/formatting so that instead of displaying "1357924" they see "$1,357,924"?
Best answer by AnthonyR
Unfortunately there is no built in method to handle this, but if you add an html span with an id of "number". You can use the following JavaScript added to the question to have it dynamically update the span with your number. This JavaScript assumes that the element you would like to pipe in is called "EDNumber" update appropriately for your situation:
Qualtrics.SurveyEngine.addOnReady(function()
{
var number = parseInt("${e://Field/EDNumber}")
$('number'). update(new Intl.NumberFormat().format(number));
});
Example html for the question:
`This is my number: <span id='number'></span>`
What's nice about this is that it will format numbers according to the locale of the respondents computer.
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.