Fix an Acrobat JavaScript Condition That Does Not Populate Form Fields
Question details
The user needs an Acrobat JavaScript loop to populate form fields based on a drop-down value.

- 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.
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.
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.
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.
In the script editor, replace the assignment condition with `if (i1 == expv)`, keeping the existing field-population statements inside the condition.
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)`.
Save the script, close the field properties, and select an option in the drop-down. Check whether the intended target fields populate.

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.

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.




