Addition combining variable like they were text instead of adding in server connect

Version 5.5.3
Apple
asp classic

I have a server script that is combining variables instead of adding them. There are three variables, they are all type number and I’m trying to add them like this:

three variable values: varDLGpricing = 1950, varMissouriTax=160.39, and varDLGshipping = 25

When seeing the variable in the browser it showing up as 1950160.3925, like it just combining them in a text field and not doing addition as it should.

I’m banging my head against the desk at this point. Any ideas?

No need to bang the head against the desk, this is a very easy thing to solve :slight_smile:

It looks like it’s doing "1950" + "160.39" + "25" instead of 1950 + 160.39 + 25

So, convert each variable to a number by using the (paraphrased) “convert to number” formatter on the Set Value expression(s)

yeah I’ve tried that too…

Then this becomes a bug report, unfortunately

You might want to put a screenshot of such attempt to convert the variables to a number

Try wrapping the entire thing in parentheses.

1 Like

This is a common issue for me, and the parentheses always seems to fix it!

then these are strings.
Make sure to convert each of these to numbers, when doing the sum.

Its weird after further examination I was able to get it to work correctly.

If I only added the two values together then it would work (varDLGpricing + varDLGshipping). I finally made the whole expression by adding .toNumber() to the varMissouriTax variable and then the whole expression worked. This was at the end of a long day when I was having this issue. I just thought it was strange because the value in the form was set to number, the post variables in the server action were set to number, but still had to convert it. Weird. But problem solved!

The form variables (POST variables) are always strings. The type you set is not changing their output, it just tells the data picker what data to expect.

Gotcha! Thanks