/ Id-Extras Forum / subtraction of two fields / Reply To: subtraction of two fields
May 11, 2021 at 8:18 pm
#6382
Participant
Hi Jennifer,
Even Acrobat itself doesn’t offer a simple way to do subtractions. Not quite sure why, but probably because x – y (and x / y) is not the same as y – x and y / x (as opposed to addition and multiplication, which are commutable).
So a custom calculation script is needed to handle this.
The basic idea is as I mention in this thread: http://id-extras.com/forum/viewtopic.php?id=53
In your case, we would need to modify it a little, like this:
To get the value of a field, use this command:
Code:
this.getField(“Field1”).value
To update the value of the selected field, use:
Code:
event.value = …
So putting it all together, try the following as your custom calculation script:
Code:
event.value = this.getField(“Field1”).value – this.getField(“Field2”).value
Does that work?
Ariel