Skip to main content
Inspiring
November 18, 2016
Question

$50.00 + $50.00 concatenated as $5050.00.

  • November 18, 2016
  • 1 reply
  • 440 views

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 has been closed for replies.

1 reply

Inspiring
November 18, 2016

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.

ODuinnAuthor
Inspiring
February 15, 2017

I apologize for not responding sooner. Since the switch from AcrobatUsers.com I did not know I needed to log in and look at my content to see answers; I thought I would receive an email notification that someone had answered.

It's been 2 months since my post. I had created three variables, the first two referencing numeric formatted text fields [example var num1 = +getField("num1").value and var num2 = +getField("num2").value] . (I may have been referencing the fields as "this.getField" instead of "+getField" but don't recall now.) The third variable did not reference a field but rather was a variable adding the first two, as in "var num3 = num1 + num2" and then I would assign the value of var num3 to a third field, with the result being, for example, 50 + 50 = 5050 instead of 100.

This was resolved by creating another field to receive the value of num1 + num2

try67
Community Expert
Community Expert
February 15, 2017

Post your full, actual code, please.