• 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 to show/hide layers and text fields

New Here ,
Mar 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

Hello, 

 

I am new to Acrobat/Javascript and have been using tutorials on here to come up with a barebones worksheet. I am using this code to show different text fields & layers based on drop down selection but the text fields for HHG & NTS are not showing up when testing. This is the code I am using;

 

var layers = this.getOCGs();
var v = event.value;
for (var i = 0; i < this.layers.length; i++) {
if (layers[i].name == "HHGNTSc1" && v == "Household Goods (HHG)") {
layers[i].state = true;
this.getField("Group1").display = display.visible;
this.getField("Group2").display = display.hidden;
} else if (layers[i].name == "HHGNTSc1" && v == "Storage (NTS)") {
layers[i].state = true;
this.getField("Group1").display = display.visible;
this.getField("Group2").display = display.hidden;
} else if (layers[i].name == "UBc1" && v == "Unaccompanied Baggage (UB)") {
layers[i].state = true;
this.getField("Group2").display = display.visible;
this.getField("Group1").display = display.hidden;
} else if (v == "Select Shipment Type") {
layers[i].state = false;
this.getField("Group1").display = display.hidden;
this.getField("Group2").display = display.hidden;
} else {
layers[i].state = false;
this.getField("Group1").display = display.hidden;
this.getField("Group2").display = display.hidden;
}
}

 

Thank you.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

193

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 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

Where did you place the code?

Did you make sure that the value of the event is really want you're comparing it to in your code? If it's off even by a single character it won't work.

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 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

LATEST

Your script shows the fields only when the layer with the name "HHGNTSc1" is the last layer.

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