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, Macintosh

Views

227

Likes

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

Most Valuable Participant , 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).

Likes

Translate

Translate
Most Valuable Participant ,
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).

Likes

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?

Likes

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
Most Valuable Participant ,
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;

Likes

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.

Likes

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