How to Create an Acrobat Form Script for Length, Width, and Height Calculations
Question details
The user needs to automate a specific calculation (multiplying length, width, and height, then dividing by 10) within a fillable PDF form field.

- Product
- Adobe Acrobat / PDF Forms
- Device & OS
- not provided
- Scenario
- Automating mathematical calculations within a fillable PDF document to instantly display volume or shipping metrics based on user inputs.
- Observed behavior
- A target result form field must dynamically execute the math formula and display the correct calculated result when numeric values are entered into the dimension fields.
Ensure you have Adobe Acrobat Pro or a compatible PDF editor that supports JavaScript form calculations, and verify that your input fields for Length, Width, and Height are already created and clearly named in your document.
Add a Custom JavaScript Calculation to the PDF Form Field
Apply a custom JavaScript code to the target result field's properties to accurately perform the required multiplication and division.
While standard Acrobat calculation properties allow simple sums or products, complex formulas with mixed operations (like multiplying dimensions and dividing the total) require a custom calculation script.
Open your PDF document in Adobe Acrobat Pro, click on the 'Tools' menu, and select 'Prepare Form' to activate editing mode for your fields.
Right-click on the destination text field where you want the final calculation to appear, and select 'Properties' from the context menu.
In the Properties dialog box, click on the 'Calculate' tab located at the top of the window.
Choose the option labeled 'Custom calculation script' at the bottom of the tab, and then click the 'Edit' button next to it.
Type or paste the following code into the editor: var l = Number(this.getField("Length").value); var w = Number(this.getField("Width").value); var h = Number(this.getField("Height").value); event.value = (l * w * h) / 10;
Click 'OK' to save the script, then click 'Close' on the Properties window. Switch to 'Preview' mode at the top right to test the form by entering numbers into the dimension fields.

Discover WPS Office for All Your Document Needs
If you frequently work with digital documents and need a powerful, cost-effective tool to edit, manage, and fill forms, WPS Office provides a highly capable and lightweight suite.

Frequently Asked Questions
Why is my PDF form calculation script returning a zero or an error?
This commonly occurs if the field names referenced in your JavaScript do not exactly match the actual form field names. Double-check for typos, extra spaces, and case sensitivity. It can also happen if the input fields contain text characters instead of numbers.
Do I have to use JavaScript to multiply fields in Acrobat?
If you only needed to multiply the fields together, you could use the built-in 'Value is the product (x) of the following fields' option in the Calculate tab. However, because your specific formula requires dividing that product by 10, a custom JavaScript calculation is necessary.
How do I ensure users only enter numerical values into the dimension fields?
To force number inputs, right-click each of the input fields (Length, Width, Height), select 'Properties', navigate to the 'Format' tab, and choose 'Number' from the 'Select format category' dropdown menu.




