Copy link to clipboard
Copied
Hello, I am a bit new to writing calculations in Adobe form fields. I am attempting to have individual fields calculate a given formula. Ex: (Given Number)*.0037. So that when a user fills the form with a whole number the field multiplies that number by .0037 to provide the calculated value we are required to display on our form.
I have tried multiple formulas. This following formula seems to work to make the calculation:
// Custom Validate script for text3
if (event.value) event.value = +event.value * .0037
However, the issue is that when I create the next form field (Text4) and enter a number into the field to be calculated the previous field (Text3) recalculates. Then if I highlight and change the number in (Text3), (Text4) recalculates.
How to I separate the fields so they do not calculate off each other? I want each field to be it's own calculation without influence from any other field on the form. Thank you for any help you can provide.
Copy link to clipboard
Copied
You state that the code is entered into a Validate, but the behavior you describe would only happen if the code was a calculation script is on the field where the data is entered? So that the field performs a calculation on itself? If true, then that is a really bad idea. The Calculate event is triggered every time any field on the form is changed. Make sure it is a custom Validate script and no calculations are taking place on any of the fields.
Also, there is no need for the "if" statement in the code.
Copy link to clipboard
Copied
You state that the code is entered into a Validate, but the behavior you describe would only happen if the code was a calculation script is on the field where the data is entered? So that the field performs a calculation on itself? If true, then that is a really bad idea. The Calculate event is triggered every time any field on the form is changed. Make sure it is a custom Validate script and no calculations are taking place on any of the fields.
Also, there is no need for the "if" statement in the code.
Copy link to clipboard
Copied
Thom,
Yes, you were spot on with what I was doing wrong. Your solution worked perfectly. Such a simple fix that I was struggling to resolve. I now have a much better understanding of how the form fields function. Thank you for your answer!!
Copy link to clipboard
Copied
You're welcome. Consider marking my answer as correct to close out the thread.