Copy link to clipboard
Copied
I am trying to write this JavaScript code in our adobe PDF to ensure it pulls from different text boxes that are filled in when completing the document and then calculated together at the bottom. My experience with JavaScript is little to none so I have been looking at training videos and testing so many different scripts.
So far this is what I have - the words like Pay, BR, HW, Salary, and Fee are defined within the document itself and is defined when someone fills out the form, adding that information:
let HC = 'Pay*1.37';
let GM = 'BR-HC';
let CP = 'GM*HW';
let TF = Salary*Fee
TF-CP;
I am thinking my issue is not telling it to calculate TF - CP so it is therefore not providing me with any final calculations. Any assistance here would really help me figure out where I went wrong.
Copy link to clipboard
Copied
To add up to mentioned above, also use 'var' instead of 'let' and if you want to show result of TF-CP in field use event.value,
This is just example script:
var HC = this.getField("Pay").value*1.37;
var GM = this.getField("BR").value-HC;
var CP = GM*this.getField("HW").value;
var TF = this.getField("Salary").value*this.getField("Fee").value;
event.value = TF-CP;
Copy link to clipboard
Copied
To access the value of a field you must use:
this.getField(" field name ").value
Copy link to clipboard
Copied
Thank you so much!
Copy link to clipboard
Copied
To add up to mentioned above, also use 'var' instead of 'let' and if you want to show result of TF-CP in field use event.value,
This is just example script:
var HC = this.getField("Pay").value*1.37;
var GM = this.getField("BR").value-HC;
var CP = GM*this.getField("HW").value;
var TF = this.getField("Salary").value*this.getField("Fee").value;
event.value = TF-CP;
Copy link to clipboard
Copied
That makes so much more sense! Girl you are a life saver! I can't be more grateful for you!
I looked high and low for tutorials to see what I was doing wrong!

