Skip to main content
Participant
March 21, 2022
Question

Drop down to show/hide layers and text fields

  • March 21, 2022
  • 2 replies
  • 333 views

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.

This topic has been closed for replies.

2 replies

Bernd Alheit
Community Expert
Community Expert
March 21, 2022

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

try67
Community Expert
Community Expert
March 21, 2022

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.