Copy link to clipboard
Copied
Good Morning All,
I am in the process of creating a PDF form that i require a value to be calculated when the value is modified in a different field. I have been searching around the forum and i have found the following post Help with rounding writing a function for rounding down. .
I have modified the code to that shown below to fit my situation and fields.
var result = (Number(this.getField("ModuleWidth").value-12)/180;
event.value = Math.floor(Math.abs(result));
This is calculating the value correctly however is isn't carrying out the rounding and then only displaying the rounded result to one whole number.
Basically i am wanting to display the whole number of the calculated value regardless of whether or not its 4.99 or 4.01 so it always rounds down to a whole number.
Also currently if i change the value of the figure in the driving the field the calculating value doesn't seem to be updating at all.
I look forward to hearing from you soon.
Thanks in advanced
Frosty
Copy link to clipboard
Copied
Try this:
var result = (Number(this.getField("ModuleWidth").valueAsString)-12)/180;
event.value = Math.floor(Math.abs(result));
Copy link to clipboard
Copied
Hi Bernd,
Thanks for your reply. I have tried putting this in the custom calculation script property of the text field however the field doesn't seem to calculate. There are no syntax errors being displayed for the script but when i change the value of the ModuleWidth field nothing displays in the field.
As such i don't know whether or not this has resolved the issue. Any ideas?
Frosty
Copy link to clipboard
Copied
Check the field calculation order.
Copy link to clipboard
Copied
how does the calculation order work as i currently have it at the bottom as that's the last thing i want to calculate after something has changed but obviously that is incorrect
Copy link to clipboard
Copied
Post a screenshot of the field calculation order.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now