
1. Re: How do I calculate the difference between two numbers in text fields
George_Johnson Oct 17, 2010 9:21 AM (in response to highviewgb)You can use the simplified field notation option, but first your input field names have to be changed so they do not contain any spaces or punctuation. For example:
TotalAssets  TotalLiabilities
If you want to use JavaScript, which will be required if you ever get into more complicated calculations, you can use something like the following as the fields custom Calculate script (Net worth):
(function () {
// Get field values as numbers
var v1 = +getField("total assets").value;
var v2 = +getField("total liabilities").value;
// calculate this field value
event.value = v1  v2;
})();
There are no restrictions on field names when using JavaScript.

2. Re: How do I calculate the difference between two numbers in text fields
highviewgb Oct 17, 2010 11:34 AM (in response to George_Johnson)Thank you so much George, it works perfectly!
Have a great day!
Judy

3. Re: How do I calculate the difference between two numbers in text fields
dradams89 Feb 14, 2017 11:34 AM (in response to highviewgb)Good Morning George,
I used the script you posted in this forum and it worked fantastic but the value it returns is either positive or negative depending on the two cells I'm using. Can this be modified so the result only returns a positive number? Then I would be able to complete other calculations.

4. Re: How do I calculate the difference between two numbers in text fields
try67 Feb 14, 2017 12:04 PM (in response to dradams89)And what should it show if the result is actually negative, then?

5. Re: How do I calculate the difference between two numbers in text fields
George_Johnson Feb 14, 2017 4:45 PM (in response to dradams89)If you mean that you want to determine the absolute value of the difference, then just change the last line to:
event.value = Math.abs(v1  v2);

6. Re: How do I calculate the difference between two numbers in text fields
ihometech@gmail.com Nov 29, 2017 11:00 AM (in response to George_Johnson)Okay, for some reason that did not work for me.
My input is like this:
(function () {
// Get field values as numbers
var v1 = +getField("Text178.0").value;
var v2 = +getField("Text178.1.0").value;
// calculate this field value
event.value = v1  v2;
})();
The values are 25 for Text178.0 and 57 for Text178.1.0 so I would expect my answer to be 32. I am getting 0 (zero).
Also, out of curiosity, why would Adobe NOT add something so simple as a subtract function under calculate?
Thanks!

7. Re: How do I calculate the difference between two numbers in text fields
George_Johnson Nov 29, 2017 11:21 AM (in response to ihometech@gmail.com)Check for errors in the JavaScript console by pressing Ctrl + J.