Copy link to clipboard
Copied
Hi!
I'm trying to create a calculated field that would display a calculated value based on values entered into two other fields in my document. If numbers are entered, it would produce a number. If nothing is added, it would stay blank. If N/A is written in the fields, then the same N/A would hypothetically appear in the calculated field. Whenever I preview and put test values into the two fields, nothing is produced in the calculated field. I'm not sure if I'm missing something here to get the value to show. Here's my code:
var m = this.getfield(MEASURE1).value
var t = this.getfield(TEMP1).value
if (m === "" || t === "") {
event.value = ""
} if (m === "N/A" && t === "N/A") {
event.value = "N/A"
} else {
event.value = m / (2^((77-t)/27))
}
I'm relatively new to javascript in general, and same for Acrobat, so any help would be appreciated!
Copy link to clipboard
Copied
Check the Javascript console for errors.
Copy link to clipboard
Copied
No errors appear
Copy link to clipboard
Copied
That's not possible, since your code contains multiple errors. Do you know how to look for JS error messages in Acrobat?
Copy link to clipboard
Copied
I only know the ones that would appear at the bottom of the console, but if there is another way to check I definitely don't know it. How would I go about that?
Copy link to clipboard
Copied
Yes, that's the place (assuming you mean the JS Console). Do you not see any error messages there after you change the value of one of the fields?
Copy link to clipboard
Copied
No, it let me select okay with no issue and no error messages. If you dont mind, what's wrong with the code? maybe thats whats stopping it from working?
Copy link to clipboard
Copied
- There's no method called "getfield".
- You did not place the field names in quotes.
- The "^" symbol is not what you think it is in JS.
- Your first if-statement is irrelevant because of the second one.
Copy link to clipboard
Copied
I used ^ because thats listed in acrobat as an operator, but im assuming its ** instead then. Ill try these tips out, thank you!
Copy link to clipboard
Copied
You can't write code with guesses and assumptions. If you're trying to calculate X-to the power of-Y I suggest you google "JavaScript math power".
Copy link to clipboard
Copied
Where did you see it listed?
Copy link to clipboard
Copied
https://helpx.adobe.com/sign/using/calculated-fields.html is where adobe says to use '^' as an exponent operator
and ** is the operator for exponent in JS. Not assumptions or guesses, just contradicting information. I took a single course, day two working with it and am still learning, so you can understand where I got it wrong the first time. But thank you, I'll figure it out from here!
Copy link to clipboard
Copied
This article is about Adobe Acrobat Sign, not Adobe Acrobat. The names are similar, but the applications are quite different.