PDF Editing Issues

Fix an Acrobat JavaScript Condition That Does Not Populate Form Fields

Rana GarciaRana Garcia Nov 24, 2026 868 views

Question details

The user needs an Acrobat JavaScript loop to populate form fields based on a drop-down value.

Fix an Acrobat JavaScript Condition That Does Not Populate Form Fields
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form script reads and splits drop-down data, then compares an export value with a loop index before populating target fields.
Observed behavior
The script reads and splits the data, but the condition does not evaluate as intended and the target fields remain unpopulated.
Before you start

Open the PDF in Acrobat and locate the form script containing the loop. Check the drop-down field's export values and the names of the target fields.

Solution 1Recommended

Compare the loop index with the drop-down value

Use this fix when the condition uses a single equals sign and assigns a value instead of comparing it.

In JavaScript, = assigns a value, while == compares values. The loose equality operator also allows a numeric string to be compared with a number.

1
Open the form script

In Acrobat, open Prepare a form and select the form field associated with the script. Open its Properties and find the JavaScript action or calculation containing the loop.

2
Correct the condition

In the script editor, replace the assignment condition with `if (i1 == expv)`, keeping the existing field-population statements inside the condition.

3
Check the export value

In the drop-down field's Properties, review the Options list and confirm that the selected item's export value corresponds to the loop index. If necessary, convert a numeric export value with `Number(expv)` and compare it using `i1 === Number(expv)`.

4
Test the form

Save the script, close the field properties, and select an option in the drop-down. Check whether the intended target fields populate.

Compare the loop index with the drop-down value
Check empty values: If you use Number(expv), handle empty or missing values separately: Number("") returns 0, which may unintentionally match the first loop index.
Free Microsoft Office alternative

Work with PDF and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with Office documents and PDFs. Its format compatibility makes it easy to move existing files into WPS, though it does not debug Acrobat JavaScript.

Open and work with PDF documents alongside other office filesCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar interface for moving from Microsoft OfficeFree and lightweight for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Why does a single equals sign cause the condition to fail?

In `if (i1 = expv)`, the single equals sign assigns expv to i1 instead of comparing them. Use `if (i1 == expv)` to compare the values.

Where can I check a drop-down item's export value?

In Acrobat, open Prepare a form, open the drop-down field's Properties, and check the Options list for each item's export value.

Should I use == or === for the loop comparison?

Use `==` if a numeric string needs to match a numeric loop index. Alternatively, validate the export value, convert it with `Number(expv)`, and use `i1 === Number(expv)`.

What should I check if the fields still do not populate?

Confirm that the selected export value matches an index in the loop and that the target field names used by `getField` match the names in Prepare a form.