I have custom script that formats a value as currency (with 0 decimal places), but I need it to also add in the thousands comma separator. Any help would be appreciated! Here is an example of the current code:
[question(‘value’), id=’mp’,moneyformat=’0’] — returns value of “$15000” instead of “$15,000”
I suspect it will, I’m just not sure how to incorporate it so that it works.
It is a custom PHP script. In pseudo code it would look something like this:
%%xvalue = sgapiGetValue(20); // get the response value to be formatted
%%decimals = 0;
%%dec_point = ”;
%%thousands_sep = ‘, ‘
%%xformattedvalue = ‘$’ . sgapiNumberFormat(%%value,%%decimals,%%dec_point,%%thousands_sep);
If you prefer, you can skip defining the decimals, decimal point, and thousands separator as variables and just plug them into the NumberFormat function.
There is no function for adding a currency sign, but it is easy enough to insert it in front of the function.
The last step of your script depends on what you want to do with the formatted value.
I wonder if this function will help in further formatting the output: