These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Invisible Subform until 1 of 2 items is picked from a drop-down list

Chayter
Registered: Mar 24 2011
Posts: 8
Answered

Ok, so I have this working perfectly except I want the subform to appear when 1 of 2 options are selected from the drop-down list. I have it working perfectly for when one item is picked from the drop-down list using:
if(DropDownList2.xfa.event.change == "Farm"){
FarmBuilding.presence = "visible";
}
else{
FarmBuilding.presence = "invisible";
}
How to I add another item to this script so that when it is chosen from the drop-down list, this same FarmBuilding subform appears? ( I want the subform to appear when Farm is picked from the drop-down list and when Farm + IR is picked from the drop-down list).
 
I have tried using:
if(DropDownList2.xfa.event.change == "Farm" || "Farm + IR"){
FarmBuilding.presence = "visible";
}
else{
FarmBuilding.presence = "invisible";
}
but that did not work.
Thanks!

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You've got the right idea, but the "if" syntax is incorrect.

if( (xfa.event.change == "Farm") || (xfa.event.change == "Farm + IR") ){
FarmBuilding.presence = "visible";
}
else{
FarmBuilding.presence = "invisible";
}


Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Chayter
Registered: Mar 24 2011
Posts: 8
Thanks Thom but that does not seem to work.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Accepted Answer
Which part doesn't work? The script is correct in form and syntax. So the issue may be the values. Add this code to the top of the script.

console.println("Change Val=" + xfa.event.change);

When you open the form in Acrobat, also open the JavaScript Console. You'll be able to see how the values are seen by the script as they are being selected on the form.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Chayter
Registered: Mar 24 2011
Posts: 8
Ok, got it. Thanks!