Skip to main content
jasonf8378156
Participant
March 7, 2019
Beantwortet

Drop down menu shows layer, hides the rest (newbie)

  • March 7, 2019
  • 1 Antwort
  • 1673 Ansichten

I have 30 layers that I created in InDesign and exported to PDF (multiple pages). I created a dropdown menu with corresponding item lists. I want to be able to show only the layer selected from the dropdown list (plus keep the main header layer active at all times). I found this post that almost worked for me, but it kept previously selected layers active once I changed the selection. I need the the other layers to hide if the selection changes. Thank you for your time, and please take it easy on me, this is my first attempt at Javascript!

Dieses Thema wurde für Antworten geschlossen.
Beste Antwort von try67

That code should have worked in your case... Try this version of it, instead:

 

var ocgs = this.getOCGs();
if (ocgs) {
    for (var i in ocgs) {
        ocgs[i].state = (ocgs[i].name==event.value);
    }
}

 

Place this code as the custom validation script of the drop-down field and make sure to tick the option to commit the selected value immediately (under the Options tab).

 

[Edited: Code fixed]

1 Antwort

try67
Community Expert
try67Community ExpertAntwort
Community Expert
March 7, 2019

That code should have worked in your case... Try this version of it, instead:

 

var ocgs = this.getOCGs();
if (ocgs) {
    for (var i in ocgs) {
        ocgs[i].state = (ocgs[i].name==event.value);
    }
}

 

Place this code as the custom validation script of the drop-down field and make sure to tick the option to commit the selected value immediately (under the Options tab).

 

[Edited: Code fixed]

jasonf8378156
Participant
March 7, 2019

Thank you! Is there any way to make one of the 30 layers stay visible at all times?

try67
Community Expert
Community Expert
March 7, 2019

Sure. You can add something like this before line #4 above:

if (ocgs[i].name=="Layer0") continue;