PDF Editing Issues

Duplicate PDF Form Fields with Row-Specific JavaScript in Adobe Acrobat

Adam DavisAdam Davis Nov 19, 2026 868 views

Question details

The user wants to duplicate PDF form rows so each calculated field uses the values in its own row.

Duplicate PDF Form Fields with Row-Specific JavaScript in Adobe Acrobat
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.
Before you start

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.

Solution 1Recommended

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.

1
Name the first-row fields

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.

2
Add the calculation script

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);

3
Create the additional fields

In Prepare a form, right-click each first-row field and choose Create Multiple Copies. Arrange the copies to form the required rows.

4
Check the field names

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.

5
Test each row

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.

Use Field-Name Suffixes to Calculate Each PDF Form Row
Copied scripts keep their references: Duplicating a field does not automatically rewrite hard-coded field names in its script. The suffix-based script works only when the field names follow the expected pattern and the PDF viewer supports form JavaScript.
Free Microsoft Office alternative

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.

Open and work with PDF documents alongside office filesCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFamiliar interface makes it easier to move from Microsoft OfficeFree, lightweight suite for everyday document tasks
microsoft office alternative - wps office

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.