Fix an Acrobat Combo Box Script Syntax Error
Question details
The user needs to resolve a syntax error in a JavaScript script for an Acrobat PDF form combo box.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating a PDF form with multiple drop-down fields and a combo box script.
- Observed behavior
- The combo box script reports a syntax error associated with a field or variable name.
Open the PDF in Adobe Acrobat and locate the combo box and its JavaScript in Prepare a Form. Check whether Pers.-Nr is used as a JavaScript variable, a form field name, or both.
Rename the problematic field or JavaScript variable
Replace Pers.-Nr with PersNr and update the script references to avoid punctuation in the identifier.
JavaScript identifiers cannot contain a hyphen or a period. A field name can contain punctuation when it is passed as a quoted string, but using a simple name can make references easier to manage.
In Acrobat, open the PDF and select Prepare a Form from the tools or All tools menu.
Select the affected field, open its Properties, and change the Name on the General tab from Pers.-Nr to PersNr.
Open the combo box Properties and find the script on the relevant tab. Replace any variable named Pers.-Nr with PersNr. If you renamed the field, update calls such as this.getField("Pers.-Nr") to this.getField("PersNr").
Review scripts in the other form fields for references to the old name, update them, and then use Preview in Prepare a Form to test the drop-down.

Work with PDFs and Office documents in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface and support for common Microsoft Office formats, making it easy to move existing documents into your workflow. It does not fix an Acrobat-specific JavaScript error; use Acrobat to edit and test that script.

Frequently Asked Questions
Why does Pers.-Nr cause a JavaScript error?
A period and a hyphen cannot be part of a JavaScript variable identifier. Use a name such as PersNr, or Pers_Nr, and update its references in the script.
Can an Acrobat field name contain a hyphen?
Yes. A field name with a hyphen can be passed as a quoted string, for example this.getField("Pers.-Nr"). Renaming the field is optional if the quoted name is not the cause of the error.
Where do I change a field name in Acrobat?
Open Prepare a Form, select the field, and open its Properties. Change the Name on the General tab, then update scripts that refer to the old name.
How can I check whether the combo box works after editing?
In Prepare a Form, select Preview and try the drop-down. Also test any other fields whose scripts reference the renamed field.




