Calculations Multiplying When I Enter A Value Into A Different Field
- November 2, 2023
- 2 replies
- 3162 views
So, I've been working on this form for call notation for our company. Most of fields are just entry fields for customer information and drop-downs for certain types of customers/calls. The issue I'm running into is on the bottom, where I am trying to calculate how much a transport would cost based on the options chosen in earlier fields. I can't even get through the mileage part yet, let alone the total estimate cost that would be using conditionals. The problem I'm having is that I put the code into the "Custom Calculation Script" under the "Calculate" tab. I am doing this is multiple fields, but changing the field name and calculation each time, but when I go to test the calculations. The first field I try works great, then I go to the second field to calculate a second number and calculates the value again, this time by the newer value. So, for example, I've got a "Mileage" field that multiplies the field entry by 3.25 (aka Cost Per Mile). I have used three different types of code for this and all have the same issue:
event.value = event.target.value * 3.25;
event.value = getField("Mileage").value * 3.25;
event.value = this.getField("Mileage").value * 3.25;
Say I enter the value 19 into this field. It will calculate it to 61.75, which is correct. But then, I will move on to another field and enter a value. As soon as I hit Enter or Tab, it will calculate that second field, but will also calculate this first Mileage field again. Resulting in an output of 200.69 (I have a number format on both fields so that it rounds to the hundreth place instead of having a long decimal).
I'm super confused with this and it's getting frustrating because I cannot move onto the even more complicated conditional calculations and whenever I research this issue, all the solutions are telling me to do exactly this code I have already tried.
Any help is greatly appreciated! Note that I am using Adobe Acrobat Pro and am into the "Prepare a form" editor.
