
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);