How to Create a PDF Button That Jumps to a Page Based on a Score
Question details
The user needs to set up a PDF form button to automatically navigate to different specific pages depending on a numeric score value entered in a designated text field.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF quiz, assessment, or dynamic form that routes users to customized outcome pages based on their score.
- Observed behavior
- A single interactive button reads the score field, evaluates which predefined range the score falls into, and jumps to the corresponding zero-based page number using JavaScript logic.
Verify the exact name of your score text field (e.g., 'Score') and calculate the zero-based target page numbers for your destination pages before applying the script.
Use a MouseUp JavaScript Action on the Button
Attach a custom JavaScript snippet to the button's action properties to evaluate the score field and trigger the corresponding page jump.
In PDF JavaScript processing, page numbering is strictly zero-based. This means that the first page is considered page 0. If you want a user to land on page 10, your script must point to pageNum 9. Furthermore, converting the text field string into a numeric value is essential for mathematical range evaluations.
Right-click the button in your PDF form editor and select 'Properties'.
Go to the 'Actions' tab, choose 'Mouse Up' as the Trigger, and select 'Run a JavaScript' as the Action, then click 'Add'.
In the JavaScript Editor window, type: var score = Number(this.getField("Score").valueAsString); (Replace "Score" with your actual text field name).
Add 'if' statements to define your ranges and target pages. For example: if (score >= 0 && score <= 5) this.pageNum = 9; if (score >= 6 && score <= 10) this.pageNum = 19;
Click 'OK' to save the script, close the Properties dialog, exit form editing mode, and test the button by entering different scores.

Easily Create Interactive PDFs with WPS Office
WPS Office offers a feature-rich PDF editor that makes it incredibly simple to add form fields, customize interactive buttons, and manage complex document navigation without needing expensive alternatives.
- 1. Open Your Document: Launch WPS Office and open your PDF file using the built-in PDF editor.
- 2. Access the Form Tab: Navigate to the 'Form' tab on the top ribbon to reveal interactive controls.
- 3. Insert Form Controls: Click on 'Text Field' or 'Push Button' to draw the necessary interactive elements onto your page.
- 4. Configure Actions: Double-click your new button to open its properties, where you can customize triggers and assign interactive behaviors.

Frequently Asked Questions
Why does my PDF button jump to the wrong page?
This usually occurs because PDF JavaScript uses zero-based page numbering. If you want the button to take users to page 30, your script needs to read 'this.pageNum = 29;'.
Will this JavaScript button work on mobile PDF viewers?
Not necessarily. Many basic PDF viewers and default mobile readers do not support or actively block custom JavaScript executions. It is highly recommended that users open the interactive PDF in a robust desktop application like WPS PDF or Acrobat.
How do I make sure the score is read as a number instead of text?
Always wrap your field retrieval method inside the 'Number()' function (e.g., Number(this.getField("Field_Name").valueAsString)). This ensures the script treats the input as a mathematical digit for greater-than/less-than logic evaluations.




