Skip to main content
Inspiring
Nov 18, 2016 12:41 AM UTC
Question

$50.00 + $50.00 concatenated as $5050.00.

I have several numeric formatted fields scripted to be added, with a sum displayed in a "total" field. Sometimes the total is correct, so that for instance $50.00 + $50.00  totals as $100.00, but at other times $50.00 + $50.00 appears concatenated, as $5050.00. I cannot find what may be causing this and would appreciate help correcting this.

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Inspiring
Nov 18, 2016 12:52 AM UTC

Something is causing one of the values to appear to be a string.

What is the format of the fields?

Are there any null or empty fields being used in the calculation?

One can use the Number constrictor to force values to numerics.

If you include the $ symbol you are creating a string not a number.

Translate
JR Boulay
Community Expert
Community Expert
Nov 20, 2016 10:20 AM UTC

Hi.

To force values to numerics you can multiply by 1:

var nTotal = (50.00 * 1) + (50.00 * 1);

var sTotal = "$" + nTotal;

Translate
Acrobate du PDF, InDesigner et Photoshopographe