How to Round Up Feet and Inches in a PDF Form Calculation
Question details
The user needs to configure a PDF form calculation that automatically adds one foot to a hidden field value if the inches field is greater than zero.
- Product
- PDF Editor / Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form with measurement fields where values need conditional rounding logic.
- Observed behavior
- The user is unsure how to properly format the JavaScript calculation to round up feet without incorrectly adding feet and inches together as raw numbers.
Ensure your PDF form has separate, correctly named input fields for both 'feet' and 'inches', and create a third hidden text field where the final calculation will be displayed.
Use Conditional JavaScript to Round Up Feet
This solution applies a custom calculation script to a hidden field that checks the 'inches' value and increments 'feet' by 1 if inches are greater than zero.
Because feet and inches represent different measurement units, you cannot simply add them together using basic arithmetic (e.g., feet + inches). Instead, you must use a conditional script to evaluate the inches field before modifying the feet value.
Right-click your hidden calculation field in the PDF form editor and select 'Properties' from the context menu.
In the Properties dialog box, navigate to the 'Calculate' tab to view the calculation options for the field.
Select 'Custom calculation script' and click the 'Edit' button. Enter the following JavaScript code to perform the calculation: var feet = this.getField("feet").value; var inches = this.getField("inches").value; if (inches > 0) event.value = feet + 1; else event.value = feet;
Calculate Total Inches and Convert Back to Feet
Use this method if you need to calculate the exact total length in inches, round it up, and determine if it warrants an additional foot.
Create and Manage Interactive PDF Forms in WPS Office
WPS PDF provides powerful, intuitive tools to create, edit, and fill interactive PDF forms. Easily manage text fields, checkboxes, and properties without complex setup.
- 1. Open your PDF document: Launch WPS Office and open your existing PDF form or start a new document.
- 2. Navigate to the Form tab: Select the 'Form' tab on the top ribbon to access the interactive form creation tools.
- 3. Insert Form Fields: Click 'Text Field' and drag to place the input boxes for your measurements on the document.
- 4. Configure Properties: Double-click the inserted field to open the properties panel, where you can define names, formats, and actions.

Frequently Asked Questions
Why can't I directly add feet and inches together in PDF JavaScript?
Feet and inches are different units of measurement. Adding them together numerically (e.g., 5 + 3) will result in a raw integer (8) instead of a proper measurement conversion. You must apply custom logic or convert them to a common unit first.
How do I round a number up to the nearest integer in PDF JavaScript?
You can use the Math.ceil() function in your custom script. For example, Math.ceil(event.value) will round the calculated decimal value up to the next largest whole number.
Where do I enter a custom calculation script in a PDF form?
Right-click the specific text field, select Properties, and go to the Calculate tab. From there, choose 'Custom calculation script' and click 'Edit' to open the JavaScript editor window.




