Question
Layers not toggling with Javascript in Acrobat Reader
- September 5, 2024
- 1 reply
- 361 views
I have this document with two layers, one to show Imperial Units and one to show Metric Units

I have two radio buttons in a group to toggle the layers according to the user selection. Imperial is the default when document opens.
If the user selects the radio button "Metric" the layers toggle to show the change:

I am using this code:
var ocgArray = this.getOCGs();
for (var i=0; i < ocgArray.length; i++) {
if (ocgArray[i].name == "Imperial Units") {
ocgArray[i].state = true;
} // end-if
if (ocgArray[i].name == "Metric Units") {
ocgArray[i].state = false;
} // end-if
} // end-forThis works fine in Acrobat (Pro) but users are reporting it doesn't work in Acrobat Reader. When the "Metric" radio button is selected, nothing happens... See attached file below.
Can't see what I'm missing... Also, I don't have Reader to test, so I have to send it over to a colleague!
Thank you!
