PDF Editing Issues

How to Round Up Feet and Inches in a PDF Form Calculation

Steven ParkerSteven Parker Nov 5, 2026 869 views

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.
Before you start

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.

Solution 1Recommended

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.

1
Open Field Properties

Right-click your hidden calculation field in the PDF form editor and select 'Properties' from the context menu.

2
Access the Calculate Tab

In the Properties dialog box, navigate to the 'Calculate' tab to view the calculation options for the field.

3
Apply Custom Calculation Script

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;

Total Length Conversion: If you need a true total-length conversion rather than a simple conditional round-up, you must convert feet to inches first by multiplying feet by 12, adding the inches, and then applying Math.ceil() to the total.
Professional PDF Editor

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. 1. Open your PDF document: Launch WPS Office and open your existing PDF form or start a new document.
  2. 2. Navigate to the Form tab: Select the 'Form' tab on the top ribbon to access the interactive form creation tools.
  3. 3. Insert Form Fields: Click 'Text Field' and drag to place the input boxes for your measurements on the document.
  4. 4. Configure Properties: Double-click the inserted field to open the properties panel, where you can define names, formats, and actions.
Easily add, edit, and format interactive form fieldsFully compatible with standard PDF structures and Adobe Acrobat filesLightweight, fast, and feature-rich interface for professional document management
microsoft office alternative - wps office

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.