Trouble hiding and showing pages
- November 2, 2023
- 3 replies
- 882 views
I have a five-page pdf document and on page one I have one group of two radio buttons. If selecting Choice1 radio button I want page 3 to hide and if Choice2 radio button is selected I want pages 2, 4, and 5 to hide. I'm using the following script and no pages will hide with either radio button choice. I have tried saving as a test document and removing all fields so I only have the two radio buttons with the following script and text on all the other pages and it still won't hide any pages.
var radio = this.getField("Group1.Choice1"); // Replace with your actual radio button field name // Array to define the pages you want to hide or show var pagesToHide = [1, 2, 3]; // Adjusted for shifted numbering var pagesToShow = [0, 1, 3]; // Adjusted for shifted numbering if (radio && radio.value === "Choice1") { console.println("Choice1 selected - Hiding pages 2, 3, and 4."); for (var i = 0; i < pagesToHide.length; i++) { this.setPageHidden(pagesToHide[i], true); } for (var j = 0; j < pagesToShow.length; j++) { this.setPageHidden(pagesToShow[j], false); } } else if (radio && radio.value === "Choice2") { console.println("Choice2 selected - Hiding page 1 and showing all other pages."); this.setPageHidden(1, true); // Hide the first page for (var k = 0; k < this.numPages; k++) { this.setPageHidden(k, false); } } console.println("Radio button script executed successfully."); // Run this script before all other document scripts this.calculateNow();
