Skip to main content
Participating Frequently
August 2, 2022
Answered

Calculated field not showing value

  • August 2, 2022
  • 1 reply
  • 862 views

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! 

This topic has been closed for replies.
Correct answer Nesa Nurani

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

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
August 2, 2022

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

KatyaIonAuthor
Participating Frequently
August 2, 2022

It worked, thank you so much!

Would you happen to be able to explain why ** wouldnt work in this situation?

 

try67
Community Expert
Community Expert
August 2, 2022

Because that's not a valid operator in JavaScript.