How can I accept a Currency Formatted input and then do math on it?

mklubeck
mklubeck South Bend, IndianaCommunity Member, Qualtrics Brand Admin Sage ✭✭✭
edited July 13 in Custom Code

Qualtrics requires inputs to be numeric-only - not allowing "$" or "," (it accepts decimals). And a lot of times we want to accept inputs that are currency. Respondents want to see the $ and the "," between 1 and all those zeroes. But Qualtrics can't do mathematical calculations on those type of data.

Best case scenario would be to have the $ auto show up as the person types in the amount, and appropriate commas also auto entry...basically using a Currency Format. BUT then allow mathematical operations on it. Happy to have a way to create an Embedded Data variable that holds only the numerical representation and use that for the math.

Answers

  • grahulp5
    grahulp5 IndiaCommunity Member Guru ✭✭

    The best way would be to parseInt the string or maybe get the value in survey flow in numeric form and then perform the arithmetic operation. Or you can just create a function to add ',' in real time and then on pagesubmit to parseInt the value to number.

  • mklubeck
    mklubeck South Bend, IndianaCommunity Member, Qualtrics Brand Admin Sage ✭✭✭

    @grahulp5 Thanks, but I have no idea what you mean. "just create a function", "pagesubmit", and "parseInt the value to number" sound very techno but I can't put any of that into action to solve the problem.

    t

  • grahulp5
    grahulp5 IndiaCommunity Member Guru ✭✭

    Just select the text entry type question with a label and do the math operation in JS section. or if it's not important to be a text entry then just give the option as a single punch if the list is not long.