Add Two PDF Form Fields and Multiply by a Fixed Rate
Question details
Calculate a PDF form field by adding holiday and vacation hours and multiplying the total by a fixed rate of 11.

- Product
- PDF form editor, such as Adobe Acrobat Pro
- Device & OS
- not provided
- Scenario
- A form needs to calculate a value from two hour fields using a fixed hourly rate.
- Observed behavior
- The current calculation uses only one of the two fields.
Open the PDF in a form editor that supports custom calculation scripts. Check that the source field names are exactly "Holiday Hours MC" and "Vacation Hours MC", including spaces and capitalization.
Use a Custom Calculation Script in the PDF Form
Use this method to update the calculated field automatically when either hour value changes.
The script converts both field values to numbers before adding them, then multiplies their sum by 11.
In Adobe Acrobat Pro, open the PDF and choose All tools > Prepare a form.
Double-click the field that should display the calculated result, then select the Calculate tab.
Select Custom calculation script, click Edit, and enter: var holiday = Number(this.getField("Holiday Hours MC").value); var vacation = Number(this.getField("Vacation Hours MC").value); event.value = 11 * (holiday + vacation);
Close the field properties, save the PDF, and enter values in both hour fields. For example, 2 holiday hours and 3 vacation hours should produce 55.

Calculate the Fixed-Rate Total in WPS Spreadsheets
Use WPS Spreadsheets to calculate the total from both hour values, then enter the result manually in a suitable PDF field. This workaround does not add an automatic calculation script to the PDF.
- 1. Enter the hour values: Open WPS Spreadsheets and enter holiday hours in cell A1 and vacation hours in cell B1.
- 2. Calculate the total: In cell C1, enter =(A1+B1)*11 and press Enter.
- 3. Transfer the result: Open the PDF in WPS Office and enter the value from C1 into a suitable editable result field. Recalculate and update it manually if the hours change.

Frequently Asked Questions
Why does the script convert each field value to a number?
PDF form values may be stored as text. Number() converts them before addition so that, for example, 2 and 3 are added rather than joined as 23.
What if my PDF field names are different?
In Prepare a form, check each field's name in its properties. Replace the names inside getField() with the exact names used in your PDF.
What happens if an hour field is blank?
In this script, Number() converts an empty field value to 0, so the calculation can use the other field's value. Enter numeric values rather than text in the hour fields.
Why does the calculated field not update in my browser?
Some browser PDF viewers do not support PDF form JavaScript. Open the saved form in a compatible viewer with JavaScript enabled and test both source fields again.




