Copy link to clipboard
Copied
I'm trying to write a javascript calculation in a PDF form using cos and sin functions but I can't get javascript math functions to work. Any suggestions?
Copy link to clipboard
Copied
What do you mean you can't get them to work? Here's the reference.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
No, I can't get it work.
I tried something simple like:
event.value=math.cos(0);
and
event.value=math.PI
but it didn't return anything. No error either, it just didn't change the cell value from the last java formula I entered that did work.
Copy link to clipboard
Copied
Javascript is case-sensitive. Use Math. not math.
Copy link to clipboard
Copied
What do you mean you can't get them to work? Here's the reference.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
No, I can't get it work.
I tried something simple like:
event.value=math.cos(0);
and
event.value=math.PI
but it didn't return anything. No error either, it just didn't change the cell value from the last java formula I entered that did work.
Copy link to clipboard
Copied
Javascript is case-sensitive. Use Math. not math.
Copy link to clipboard
Copied
That was simple, thanks!
Here's the formula I'm using for converting a magnitude and angle to the X coordinate and it works great now:
event.value=this.getField("Magnitude”).value*Math.cos(this.getField("Angle").value/(180/Math.PI));

