Use the addSeparators
method to reformat a number value with comma separators. This is a corollary to the number format
tag. Where number format
acts on values in real time as digits are entered by respondents into fields, addSeparators
retroactively adds comma separators to a number already captured.
Syntax
addSeparators(Number or variable storing number here)
If one were localizing the number where the separator wasn't a comma, an additional parameter specifying the separator is added. In this case, a period will be used instead of the default comma:
addSeparators(Number or variable storing number here,'.')
Example
Retroactively add separators to piped answer
In this example, the Q3 response will be stored as a number with no commas, e.g. "4216". The addSeparators
function will display it as "4,216". Note the '$' in front of the function; it will be displayed as a dollar sign on the page, rather than interpreted as a variable reference as with '$Q3' inside the function.
Comments
0 comments
Please sign in to leave a comment.