Basic calculations in Adobe Acrobat forms are coming out incorrect. How to fix this?
- February 19, 2024
- 2 replies
- 1612 views
Just trying to calculate some basic addition, multiplying for tax, and adding the total. Something is causing my calculations to go haywire.
Here's the custom code section:
// Retrieve the values of the fields
var ContractPrice = Number(this.getField("ContractPrice").valueAsString);
var BatteryPrice = Number(this.getField("BatteryPrice").valueAsString);
var OtherPrice = Number(this.getField("OtherPrice").valueAsString); // Assuming this could be 0 or any other value
// Calculate the sum of the prices var total = ContractPrice + BatteryPrice + OtherPrice;
// Calculate the total including tax by applying 6.75% var totalIncludingTax = total * (1 + 0.0675);
// Set the result to the current field, showing total price including tax event.value = totalIncludingTax.toFixed(2); // .toFixed(2) rounds the result to 2 decimal places
