Javascript Enable/disable all buttons
Copy link to clipboard
Copied
Hi, I have an interactive PDF made with indesign (with buttons that show/hide other buttons). My client want to be able to enable or disable the buttons with one button (or two, maybe radio button?) on the first page of the PDF. Is there a way to do that?
*Note that I have an «Hidden until trigerred» function on some of my buttons.
Thank you!
Copy link to clipboard
Copied
I wonder, if they were on a layer and your 'switch' turned on/off the visibility of the layer.... could that do the trick?
Copy link to clipboard
Copied
Thank you for your answer!!!
it look like a really good idea 🙂
I check with my client if this is suitable for him, as this PDF will be opened by professors or students on different platforms.
Thanks again!!
Copy link to clipboard
Copied
Yes, this can be done with a script. You just need a list of the field names, and then to iterate over them in a loop, changing their display property from visible to hidden, or vice versa.
Copy link to clipboard
Copied
Place this script as a Mouse up action in a checkbox (not in a radio button):
if (event.target.value != "Off") {
for (var i = 0; i < this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
if (oFld.type == "button" && oFld.page == 0) {
oFld.readonly = true;
}
}
}
else {
for (var i = 0; i < this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
if (oFld.type == "button" && oFld.page == 0) {
oFld.readonly = false;
}
}
}
Acrobate du PDF, InDesigner et Photoshopographe
Copy link to clipboard
Copied
Thank you!! 🙂
it didn't work at first, but by removing « && oFld.page == 0» it works great!

