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

How can I make my subform invisible or visible in the easiest way?

Salva
Registered: Dec 7 2011
Posts: 1

Hi,
 
I'm trying to make a simple subform as invisible upon a selected value from a drop-down list by entering the following script into "change event", however it doesn't work.
 
if (List1.selectedindex > 3)
{
Subform1.presence = "invisible";
 
}
else
{
Subform1.presence = "visible";
}
 
I also made some automatic calcultations, that so far are performed well, however this is something that I don't understand. Is like the drop-down list doesn't have the rights to set the subform as "invisible"
 
Could any of you guys please tell me about this simple thing!!
 
Thank you in advance for your help!! Salva
 

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
At the time the Change event is called the list value is in transition. It has not actually changed, so the index is not yet valid. As such, the values associated with the event are members of the event object. For example, the newly selected value is in xfa.event.change. If you want to find the index, you'll need to write code that looks up the position from the selected value, not so simple.Alternatively, the index value is valid in the "Validate" event. But you have to be careful with Validate because Acrobat expects a true/false result, for the validation. Try this

Subform1.presence = (this.selectedindex > 3)?"invisible":"visible";

You may also want to read this article. A big part of getting your code to work is understanding what's going on.
How to Debug Your Script

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