Copy link to clipboard
Copied
I have a self populating table in an Acrobat document; figured out most of the simple equations but I have one slightly more complicated one that needs JavaScript and I know nada.
The reader inputs two values (a), (b)
and if I were to write the fomula in Excel I would write:
=a-(IF(b<20.5,b,20.5))+41.5
Any thoughts on how to translate this? Thanks!
If you want this to be a custom calculation script for a field, it could be:
// Custom calculation script for text field
(function () {
// Get the field values, as numbers
var a = +getField("A").value;
var b = +getField("B").value;
// Set this field's value
event.value = a - (b < 20.5 ? b : 20.5) + 41.5;
})();
but replace "A" and "B" in the getField statements with the actual field names you're using.
Copy link to clipboard
Copied
If you want this to be a custom calculation script for a field, it could be:
// Custom calculation script for text field
(function () {
// Get the field values, as numbers
var a = +getField("A").value;
var b = +getField("B").value;
// Set this field's value
event.value = a - (b < 20.5 ? b : 20.5) + 41.5;
})();
but replace "A" and "B" in the getField statements with the actual field names you're using.
Copy link to clipboard
Copied
Yes! That did it! I was close a couple of times earlier today, but didn't include the " ; "
Thank you!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now