Hide/reveal pages based on the one checkbox selection
Good day all!
Need help. I have a 3 page PDF document and if one of the checkboxes "chkHidePages" on first page is selected, last 2 pages of the PDF are not needed and i'd like them to disappear. If checkbox "chkHidePages" is unslected, then I'd need those 2 last pages to reappear. Export value is at "Yes". Mouse Up. Run Javascript.
I tried this code below and it does not work. Thanks in advance. Pls help:
// Get the checkbox field by its name
var checkbox = this.getField("chkHidePages"); // Make sure the name matches exactly
// Check the value of the checkbox field
if (checkbox.value === "Yes") {
// Hide pages 2 and 3 (page indexes 1 and 2)
this.setPageVisibility(1, false); // Page 2 (index 1)
this.setPageVisibility(2, false); // Page 3 (index 2)
app.alert("Pages 2 and 3 have been hidden."); // Debugging alert to confirm the action
} else {
// Show pages 2 and 3
this.setPageVisibility(1, true); // Page 2 (index 1)
this.setPageVisibility(2, true); // Page 3 (index 2)
app.alert("Pages 2 and 3 are visible again."); // Debugging alert to confirm the action
}
