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

need multiple checkboxes to hide/display a text box

Elya42
Registered: Mar 3 2009
Posts: 59
Answered

I am not sure if this is the place to post this question, if is not. please forgive me.

This is the question I need help with.

I have a colum of 3 checkboxes
I also have a text box in an adjacent colum.
the textbox is to be hidden until all 3 checkboxes are independently selected (there is no preferencial order in which the checkboxes are selected, but the text box cannot be displayed unless the third checkbox is selected)

Does anyone know how I can make this happen?

Elaine M

My Product Information:
Acrobat Pro 9.1, Macintosh
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
This has to be done with JavaScript, and the easiest way to implement it is with a script in single location. For example, the calculation script of the text box, assuming that the check boxes are named "Chk1", "Chk2", and "Chk3"
event.target.hidden = !(this.getField("Chk1").isBoxChecked(0) && this.getField("Chk2").isBoxChecked(0) && this.getField("Chk3").isBoxChecked(0));
The down side of doing it this way is that it's another calculation event. Calculation events are called everytime any field on the form is changed. So another more efficient way to do this(from an operational standpoint) is to put individual testing scripts in the MouseUp events of the check boxes. But this is also more of a hassle and less supportable because you have 3 scripts instead of one.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

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

Elya42
Registered: Mar 3 2009
Posts: 59
will the above code work in the MouseUp events of the checkboxes?

Elaine M

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Oh no, that code is specific to the calculation event.

For a mouse up event replace the [b]event.target[/b] with [b]this.getField("MyTextBox")[/b]

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

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

Elya42
Registered: Mar 3 2009
Posts: 59
Works perfectly, and here I was trying to use validation sripts in the checkboxes

Thank you so very much. You have saved me from a lot of stress as well as my job!!!!!!!!!!!!!!!

Elaine M

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You're welcome, could you mark the tread as answered?

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