Duplicate PDF Form Fields with Row-Specific JavaScript in Adobe Acrobat
Question details
The user wants to duplicate PDF form rows so each calculated field uses the values in its own row.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form contains repeated price, quantity, and total fields that need independent calculations.
- Observed behavior
- Duplicated calculation scripts continue to reference the original row, producing incorrect results.
Open the PDF in an Adobe Acrobat version that supports form editing, and identify the input and calculated fields in the first row. Plan a consistent naming scheme such as price.0, quantity.0, and total.0.
Use Field-Name Suffixes to Calculate Each PDF Form Row
Use this method when duplicated rows need to calculate independently without manually rewriting every script.
The script reads the suffix after the last dot in the calculated field’s name and uses it to find the corresponding price and quantity fields. The three fields in each row must have matching suffixes.
Open All tools > Prepare a form in Acrobat. Create or edit the first row’s fields and name them price.0, quantity.0, and total.0 in their field properties.
Open the properties for total.0, select the Calculate tab, and choose Custom calculation script > Edit. Enter: var name = event.target.name; var row = name.substring(name.lastIndexOf('.') + 1); var price = this.getField('price.' + row).value; var quantity = this.getField('quantity.' + row).value; event.value = Number(price) * Number(quantity);
In Prepare a form, right-click each first-row field and choose Create Multiple Copies. Arrange the copies to form the required rows.
Inspect the copied fields in Prepare a form and rename them if necessary. For example, the next row must contain price.1, quantity.1, and total.1; each later row needs its own matching suffix.
Use Preview in Prepare a form, enter different prices and quantities in multiple rows, and confirm that each total uses only the values in its row.

Work with PDFs and Office Documents 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 for easier migration, but use Acrobat to set up and test the PDF form JavaScript described above.

Frequently Asked Questions
Why do duplicated PDF fields calculate using the first row?
Copied fields retain their calculation scripts, including any hard-coded references to the first row. In Acrobat’s Prepare a form tool, edit the calculated field’s script to derive the row suffix from event.target.name.
How should I name fields for the suffix-based script?
Use the same suffix for all fields in a row, such as price.1, quantity.1, and total.1. Check the names in Prepare a form after creating copies and rename any fields that do not match the pattern.
Do I need to edit the script in every copied total field?
No. Add the suffix-based script to the first total field before using Create Multiple Copies. The copied script can then identify its own row, provided the copied field names follow the expected pattern.
Why does the calculation work in Acrobat but not in another PDF viewer?
Some PDF viewers do not support PDF form JavaScript or have it disabled. Test the completed form in Acrobat or another viewer that supports form calculations.




