How to Link Dropdown Items to Specific PDF Pages Using JavaScript
Question details
The user wants to configure a dropdown menu in a PDF so that selecting an item navigates to a specific page, and then resets the dropdown to a default option.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating interactive PDF forms with navigation menus.
- Observed behavior
- The user needs the correct JavaScript syntax to assign target page numbers to dropdown items and handle the zero-based page index.
Ensure you have a PDF editor that supports JavaScript for interactive forms, such as Adobe Acrobat Pro. Familiarize yourself with the zero-based page numbering system where page 1 is represented as 0.
Add JavaScript to the Dropdown Field for Page Navigation
Use a custom format or calculation script in the dropdown field properties to trigger page navigation based on the selected item.
By assigning a custom JavaScript code to your dropdown menu, you can listen for specific selections and change the current page view accordingly. You can also append a command to reset the dropdown value so it is ready for the next interaction.
Open your PDF in Adobe Acrobat and select the 'Prepare Form' tool from the right-hand pane.
Right-click the target dropdown field and select 'Properties' from the context menu.
Navigate to the 'Format' tab, choose 'Custom' from the Select format category dropdown, and click 'Edit' to open the JavaScript editor.
Enter the following code to handle the navigation: `if (event.value == "Item1") this.pageNum = 4; else if (event.value == "Item2") this.pageNum = 9;`
To reset the dropdown after jumping to the page, add this line below your navigation code: `this.getField("YourDropdownName").value = "DefaultOption";`

Create Interactive PDFs and Navigate Pages with WPS PDF
While advanced JavaScript requires specialized tools, WPS PDF offers an intuitive, code-free way to add hyperlinks, bookmarks, and edit PDF content directly. It is a lightweight, free alternative for managing your PDF documents efficiently.
- 1. Open your PDF: Launch WPS Office and open your PDF document.
- 2. Select the Link Tool: Go to the 'Edit' tab on the top ribbon and select 'Link' to insert a hyperlink.
- 3. Set the Target Page: Draw the link area over your text or button, choose 'Link to a Page in this Document', and enter the target page number.
- 4. Save and Test: Click 'OK' to create your navigation link, then save the document and click the link to test the navigation.

Frequently Asked Questions
Why does my PDF JavaScript navigate to the wrong page?
PDF JavaScript uses a zero-based index for page numbering. This means page 1 is `0`, page 2 is `1`, and so on. If you want to navigate to page 5, you must set `this.pageNum = 4` in your script.
How do I reset the dropdown menu after a selection is made?
You can add a script that resets the field value immediately after the navigation command executes. For example, use `this.getField("YourDropdownName").value = "Select a page";` at the end of your JavaScript code.
Can I use this JavaScript in free PDF readers?
Most basic free PDF readers do not support executing advanced JavaScript for form fields. Users will typically need a robust PDF viewer like Adobe Acrobat, Foxit, or fully-featured PDF software to utilize these interactive script features.




