• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Beginner ,
Mar 07, 2019 Mar 07, 2019

Copy link to clipboard

Copied

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!

TOPICS
Acrobat SDK and JavaScript

Views

597

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 07, 2019 Mar 07, 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.state = (ocgs.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).

Votes

Translate

Translate
Community Expert ,
Mar 07, 2019 Mar 07, 2019

Copy link to clipboard

Copied

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.state = (ocgs.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).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 07, 2019 Mar 07, 2019

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 07, 2019 Mar 07, 2019

Copy link to clipboard

Copied

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

if (ocgs.name=="Layer0") continue;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 07, 2019 Mar 07, 2019

Copy link to clipboard

Copied

LATEST

You have just remedied hours of searching and trial/error on my end. Much appreciated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines