Calculate Total Hours and Minutes in an Acrobat PDF Form
Question details
Calculate a combined hours-and-minutes total from separate drop-down fields in a PDF form.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- Each form row has separate Hours and Minutes drop-downs, and the user needs one total across all rows.
- Observed behavior
- The desired total converts every 60 minutes into an additional hour and displays the remaining minutes, such as 2:10 for 1 hour and 70 minutes.
Open the form in Adobe Acrobat and choose Prepare a form to check the exact field names. Make sure the drop-down choices have numeric export values, and create a text field for the total if one does not already exist.
Add a custom calculation to the Acrobat total field
Use a calculation script to combine all row values and display the result as hours and two-digit minutes.
The script converts each row to minutes, adds the results, and then converts the total back to hours and minutes. The example uses two rows; add more field-name pairs for additional rows.
In Acrobat, open All tools > Prepare a form. For this example, name the row fields Hours1, Minutes1, Hours2, and Minutes2, or replace those names in the script with the names already in your form.
In Prepare a form, double-click the total text field. Open the Calculate tab, select Custom calculation script, and click Edit.
Paste the following script and click OK: var rows = [['Hours1', 'Minutes1'], ['Hours2', 'Minutes2']]; var totalMinutes = 0; for (var i = 0; i < rows.length; i++) { var hours = Number(this.getField(rows[i][0]).value) || 0; var minutes = Number(this.getField(rows[i][1]).value) || 0; totalMinutes += hours * 60 + minutes; } var totalHours = Math.floor(totalMinutes / 60); var remainingMinutes = totalMinutes % 60; event.value = totalHours + ':' + ('0' + remainingMinutes).slice(-2);
Close the field properties, save the PDF, and enter 1 hour 25 minutes in the first row and 0 hours 45 minutes in the second. The total should display 2:10.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. It supports common Microsoft Office formats, making it easy to bring existing files into your workflow. Use Acrobat to create and test the custom PDF form calculation described above.

Frequently Asked Questions
How do I include more rows in the total?
In the total field's Calculate > Custom calculation script editor, add another pair of field names to the rows array, such as ['Hours3', 'Minutes3']. The names must match the form fields exactly.
Why does the total show 2:10 instead of 1:70?
The calculation converts all entries to minutes, then uses whole groups of 60 minutes as hours. The remaining minutes are displayed after the colon.
Which values should I put in the drop-downs?
In Prepare a form, open each drop-down's Properties and check its Options. Use numeric export values; for example, minutes can run from 0 to 55 in five-minute increments, and hours can run from 0 to 24 if that suits the form.
Why does the calculation work in Acrobat but not in a browser?
Some browser PDF viewers do not support Acrobat form JavaScript. Open the saved PDF in a viewer that supports it and test the drop-downs and total field there.




