How to Divide a PDF Form Field by 3 Using Acrobat JavaScript
Question details
The user needs to automatically divide a numerical value entered in a 'Total Units' PDF form field by 3 and display the exact result in a separate calculated 'Units' field.

- Product
- Adobe Acrobat Pro 2017
- Device & OS
- not provided
- Scenario
- Designing a fillable PDF form that requires automated mathematical division between interactive fields.
- Observed behavior
- The user wants to replicate a spreadsheet-style division formula within a fillable PDF form using a custom calculation script.
Ensure you are in the 'Prepare Form' mode in Adobe Acrobat Pro and that both your source field and destination field are accurately named before applying the JavaScript code.
Use a Custom Calculation Script in Adobe Acrobat
Apply a custom JavaScript code to the target form field to automatically fetch and divide the source field's value.
While Adobe Acrobat provides built-in functions for basic addition and multiplication, division requires a short custom JavaScript. The script extracts the value as a string, converts it to a number, performs the division, and sets the value of the target field.
Launch Adobe Acrobat Pro, open your PDF document, navigate to the 'Tools' menu, and select 'Prepare Form'.
Right-click the destination field (the calculated 'Units' field) where you want the divided result to appear and select 'Properties' from the context menu.
In the Field Properties dialog box, click on the 'Calculate' tab at the top.
Select the 'Custom calculation script' option and click the 'Edit' button. In the JavaScript Editor, paste the following code: event.value = Number(this.getField("Total Units").valueAsString) / 3;
Click 'OK' to save your script, then close the Properties dialog. Preview the form and type a number in the 'Total Units' field to verify that the division calculates correctly.
Manage and Fill PDF Forms with WPS PDF
While advanced JavaScript calculations require specific software like Adobe Acrobat, WPS Office provides a lightweight, highly compatible PDF editor to fill, create, and manage PDF forms seamlessly without expensive subscription fees.
- 1. Open Your PDF in WPS Office: Launch WPS Office and open your fillable PDF document using the built-in PDF editor.
- 2. Access the Form Tools: Navigate to the 'Form' tab on the top ribbon to view all available interactive form fields and highlighting tools.
- 3. Fill and Export: Click into the interactive fields to input your text or numeric data, then save or export the filled document instantly.

Frequently Asked Questions
Why is my PDF form calculation not updating automatically?
In Adobe Acrobat, the field calculation order dictates when a result updates. If your fields are calculated out of order, the division result won't update immediately. Go to 'Prepare Form' > 'More' (or the sidebar menu) > 'Set Field Calculation Order' to ensure the source fields calculate before the target field.
Can I do basic math in a PDF without using JavaScript?
Yes, for simple addition, multiplication, or averaging, you can select 'Value is the [Sum/Product/Average] of the following fields' in the Calculate tab. However, subtraction and division specifically require selecting the 'Custom calculation script' option.
What happens if the source field is empty in my division script?
If the source field is empty, the JavaScript formula usually treats it as a zero, which results in a zero displaying in the target field. To prevent this, you can wrap your script in an 'if' statement that checks whether the source field is empty before running the math operation.
Are JavaScript form calculations supported in all PDF readers?
No. While Adobe Acrobat and advanced desktop PDF editors successfully execute JavaScript, many basic web browsers and built-in OS viewers (like Apple Preview) do not support JavaScript form calculations. The form might display blank calculation fields for users on those platforms.




