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

Check Button Trouble

ashtontiarn
Registered: Jun 23 2009
Posts: 5

Hi,

I'm new to the world of Interactive forms and PDF's but unfortunately need to create one for a client. Basically the problem that I have is that I have different layers imported from Indesign where I have designed it. Each layer represents sections of the form that will show when checked with either a radio button, or a check box. I'm having a problem finding a script that will allow a check box to, when checked bring up the layer on which the certain area of information will be, and then when clicked again, it will disappear.

Im really not sure of any way that I can get it to work. I have tried to set layer visibility and it works as to showing the layer, but then, once clicked again the layer does not disappear.
If anyone has any idea a) what I'm on about, and a way to help, that would be an awesome help as this is an important job and needs to be nutted out

Thankyou.

p.s Im working on CS4 on a Mac if this helps.

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Have you read this article?

http://www.acrobatusers.com/tutorials/2006/create_use_layers

It discusses how the Layer (OCG) properties need to be set up and the JavaScript thats used to control them.

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

ashtontiarn
Registered: Jun 23 2009
Posts: 5
is there a way that I can hide a page from the person filling it in, but when the form is sent/submitted, a particular page shows up for the approver/reciever of the form????

sorry have a few other questions to ask but I will get to those later.
thanks for any help I get.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
I don't think you can hide a page, but you can have a blank page with a hidden layer (reffered to as on OCG in Acrobat JS), and when the form is sent you can set the layer's visibility to true.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Actually, you can have a hidden page, but it's tricky and may not be exactly what you need. It's called Page Templates. You can turn any page into a template from "Advanced > Document Processing > Page Templates" menu item in Acrobat 9, and "Forms > Page Templates" in Acrobat 8. Only in Acrobat 8 it's a bit trickier making the menu item visible.Once a page is a template it can be shown and hidden in Acrobat Pro or Standard, but not in Adobe Reader. This can be done from the page Templates panel or from JavaScript. So you could have the
page hidden for the user when they fill it out in Reader, but then the Form Approver could make it visible if they were using Acrobat Pro.

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

ashtontiarn
Registered: Jun 23 2009
Posts: 5
Thankyou for your help so far.
Next question...
How do I hide a page within the pdf yet show it when a check box is ticked as yes or no. So I have a check box with yes and no, if yes is checked the page stays hidden, but if no is checked the page is visible at the end of the pdf.
Thankyou again.
ashtontiarn
Registered: Jun 23 2009
Posts: 5
Me again, almost there...
So basically I'm not the greatest at explaining things, but what I have is 3 check boxes; 1,2, 3.

If 1 is checked and 2 is checked it shows OCG (submit) on page 2.
If 1 is checked and 3 is checked it shows OCG (submit) on page 3 (conference).
If 1 is UNCHECKED and 2 is checked it shows OCG (submit) on page 2.
& lastly.
If 1 is UNCHECKED and 3 is checked it shows OCG (submit) on page 4 (notification).

I can get the OCG to hide and show when the 2 and 3 buttons are checked, but I need some sort of "but script" so that if the 1st button is checked it changes where it goes.

This is what I'm working with atm.

"var b = this.getField("NoCheck02");
var a = this.getField("RadioBOX01");
var ocgs = this.getOCGs();

if ((b.isBoxChecked(0)(a.isBoxChecked(0))
ocgs[16].state = true;

if (b.isBoxChecked(1))
ocgs[16].state = false;

if (b.isBoxChecked(0))
ocgs[17].state = false;

if (b.isBoxChecked(1))
ocgs[17].state = true;"


Any help is greatly appreciated it's fairly important.
Thankyou.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
OCG (Layer) states can be used to hide content on a page, but not the entire page. It this works for you then its a much easier way to go than Page Templates.

The "isBoxChecked" function gets the on/off state for a particular widget of a check box or radio button. The widget is the instance of a field that the user sees on the page. So for check boxes there is usually only one widget on the page, whereas for radio buttons there is always more than one. Say for example that you had a male and female radio buttons on a form. Both buttons are part of the same group so they are really different widgets of the same radio button field. "isBoxChecked(0)" gets the state for the "Male" radio button and "isBoxChecked(1)" gets the state for the "Female" radio button.

Now, when setting a particular OCG state (or any value) all the logic needs to be in one place. Since the state is a boolean value that is always set to either true or false, a single expression can be used.
I don't know if this is correct for your purpose, but this is how it's done.
var bChk02 = this.getField("NoCheck02").isBoxChecked(0);var bRad01 = this.getField("RadioBOX01").isBoxChecked(0); ocgs[16].state = bChk02 && bRad01;ocgs[17].state = bChk02;

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