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

Submit button visible/hidden based on multiple check box selections

drizagon
Registered: Oct 22 2009
Posts: 41

Hello,

I have this form and I would like to show/hide submit buttons on each of the form pages based on which items are checked.

So, for example:

box 1 is checked, submit2 is visible
box 2 is checked, submit3 is visible
box 3 is checked, submit4 is visible
box 1 & 2 are checked, submit3 is visible and submit2 is invisible
box 2 & 3 are checked, submit4 is visible and submit3 is invisible
etc.

I want to be able to set the variable so that if multiple boxes are checked, it goes to the last page submit button. I have no problem getting the first 3 options to work, the problem occurs when I try to do the multiple check commands.

This works to show/hide a single check box selection

if ( this.rawValue == "1" )
CommunicationServiceRequestForm.WebChatReq.Submit2.presence = "visible";
else
CommunicationServiceRequestForm.WebChatReq.Submit2.presence = "invisible";

This is what I have for scripting so far (that doesn't hide the first of the 2 submit buttons):

if (this.rawValue == 1 || EmailChk.rawValue == 0 || PhoneChk.rawValue == 0){
CommunicationServiceRequestForm.WebChatReq.Submit2.presence = "visible"; }
else {
CommunicationServiceRequestForm.WebChatReq.Submit2.presence = "invisible";}

Any insight would be greatly appreciated!

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
It's the submit buttons that need to be modified based on criteria from multilple sources, so the script needs to be in a central location. Just like you'd do a calculation script. This one script needs to take all of the inputs into account at the same time. The show/hide for each button needs to happen in a single location. If you try to break this up into several scirpt it just gets messy.

So the correct location for the script is on the submit button. In fact you can add a calculate script to a button. The calculate script is run each time any field on the form changes value.

To get your logic correct you need to rewrite the conditions as:

Submit1 is visible when ....

BTW: you don't need to use the explicit comparison to "0" and "1". These values evalutate to boolean false and true. So you can just write the code like this;

if(EmailChk || PhoneChk)
...


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]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

drizagon
Registered: Oct 22 2009
Posts: 41
Unfortunately this doesn't work because the pages are hidden until the check box(es) is/are checked. Any other suggestions?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Well then, repeat the code on the initailize event.

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