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.
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.
Copy link to clipboard
Copied
Your script shows the fields only when the layer with the name "HHGNTSc1" is the last layer.