Copy link to clipboard
Copied
Hi! I'm trying to do a very simple calulation using 3 fields to populate a 4th field, but I can't get anything to work.
Field Name = "Base Fee 1"
Field Name = "Previously Invoiced 1"
Field Name = "Current Invoice 1"
I'm trying to subtract the Previously Invoiced and the Current Invoice from the Base Fee to calculate the Remaining Fee. This is what I've tried or things similar to it:
var a = this.getField("Base Fee 1").value;
var b = this.getField("Previously Invoiced").value;
var c = this.getField("Current Invoice").value;
var d = a-b-c;
event.value = d.value;
Do you need to start with the brackets or function start or anything like that? I'm very new to all this so I'm just trying to piecemeal things I've found googling.
Thanks for your help!
Replace
event.value = d.value;
with
event.value = d;
And check the Javascript console for errors.
Copy link to clipboard
Copied
Here is a basic tutorial on calculation scripts. It is pretty old but the info is still valid.
https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations/
Unfortunately Adobe decided to not keep the download sample file that went with the tutorial.
Hope this helps,
Dimitri
pdfscripting_com
Copy link to clipboard
Copied
Replace
event.value = d.value;
with
event.value = d;
And check the Javascript console for errors.
Copy link to clipboard
Copied
Also make sure you have right field names,you write that your fields are "Previously Invoiced 1" and "Current Invoice 1" but in your script there is no number 1 on those fields.