Use Adobe Acrobat JavaScript to Navigate to PDF Pages Based on Quiz Answers
Question details
The user wants a PDF quiz to open a result page based on selected radio-button answers.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A quiz contains radio-button fields and a confirmation button that should direct users to a result page.
- Observed behavior
- The desired result is for the confirmation button to evaluate the answers and navigate to the matching PDF page.
Open the PDF in an Acrobat version that can edit form fields and actions. Check the radio-button group names, export values, and result page locations; the example below assumes fields named Q1 and Q2 and result pages 3 and 4.
Add a JavaScript action to the Acrobat confirmation button
Use this method to send quiz takers to different PDF pages according to their radio-button selections.
Acrobat uses zero-based page numbers: this.pageNum = 2 opens the third page. The example covers two answer combinations; replace the field names, export values, and page numbers with those in your quiz.
In Acrobat, open All tools > Prepare a form. Open each radio-button field's Properties and check its group name and the export values on the Options tab.
In Prepare a form, double-click the confirmation button. On the Actions tab, select Mouse Up as the trigger and Run a JavaScript as the action, then click Add.
In the JavaScript editor, enter the following example and click OK: var field1 = this.getField("Q1"); var field2 = this.getField("Q2"); if (!field1 || !field2) { app.alert("A quiz field is missing. Check the field names."); } else { var q1 = field1.valueAsString; var q2 = field2.valueAsString; if (q1 === "A" && q2 === "B") { this.pageNum = 2; // Page 3 } else if (q1 === "A" && q2 === "C") { this.pageNum = 3; // Page 4 } else { app.alert("Please complete the quiz or check your answers."); } }
Add else if branches for the remaining valid combinations, then save the PDF. Exit form editing, select each set of answers, and click the confirmation button to verify the destination and fallback message.

Open PDF Quiz Files and Office Documents with WPS Office
WPS Office is a free, lightweight alternative for everyday PDF and document work. Its familiar interface and Microsoft Office format compatibility make it easy to move existing files. Use Acrobat to create and test the quiz's JavaScript routing; script behavior may differ in other PDF viewers.

Frequently Asked Questions
Why does pageNum = 2 open page 3?
Acrobat JavaScript counts pages from zero, so pageNum = 0 opens the first page and pageNum = 2 opens the third.
Where can I find a radio button's value?
In All tools > Prepare a form, open the radio button's Properties and check its export value on the Options tab. Compare that value with the string in your script.
How do I handle unanswered questions?
Add a fallback else branch that uses app.alert to ask the user to complete or check the quiz. You can also check each field's value before testing the valid combinations.
Why does the quiz button work in Acrobat but not another PDF viewer?
PDF viewers differ in their support for Acrobat JavaScript. Test the file in Acrobat and check Preferences > JavaScript if scripts are disabled.




