Copy link to clipboard
Copied
Hi all! I am still very new to learning javascript and using acrobat, one issue I'm running into pretty consistently.
I've made a custom calculation script in order to take in the values from two fields and display the calculation value in another field.
This is the script I've gotten to after reading a lot of different posts here, and some very basic javascript courses:
var v1 = Number(this.getField("MEASURE1").value);
var v2 = Number(this.getField("TEMP1").value);
event.value = Math.round(v1/(2**((77-v2)/27)))
MEASURE1 is the measured resistance, TEMP1 is the ambient temperature at the time of the test. Both are the names of the fields I want to pull from. The goal is to have the value automatically corrected and displayed to be more accurate and not have our test technician do it on a calculator, so we save time and have less errors.
I feel like it should be simple enough but the value will not display, is something missing?
Any input would be appreciated!
If you are trying to use exponent, you need to use Math.pow() like this:
event.value = Math.round(v1/(Math.pow(2, (77-v2)/27)));
Copy link to clipboard
Copied
If you are trying to use exponent, you need to use Math.pow() like this:
event.value = Math.round(v1/(Math.pow(2, (77-v2)/27)));
Copy link to clipboard
Copied
It worked, thank you so much!
Would you happen to be able to explain why ** wouldnt work in this situation?
Copy link to clipboard
Copied
Because that's not a valid operator in JavaScript.
Copy link to clipboard
Copied
Oh alright, must've gotten it mixed up with something else then. Thank you!!