Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Check one Acrobat Form Checkbox, and Another Checks Automatically

3,166 views
Skip to first unread message

Dale Davaz

unread,
Sep 17, 2003, 10:04:37 AM9/17/03
to
Acrobat forms-scripting gods,

I’m working with Adobe Acrobat 6.0 for Win to render a simple fillable form with text fields and checkboxes. But I’d like to implement very simple programming so that when the user clicks one particular checkbox, another checkbox also turns checked--making the 'pairing' of these items a sort of default. Users then have to “opt out” of the second checkbox (and uncheck the box) if they prefer to not have that collateral option.

Acrobat forms do support a limited form of Javascript. For example, choose the checkbox tool from the forms toolbar, right-click on the first checkbox, choose properties, click the Actions tab, and you can program an action to follow the mouse-up event for the checkbox. After perusing Adobe’s scripting reference materials, the solution probably would be something like:

var f = this.getfield("NameOfCheckbox");
f.checkThisBox(17,true);

(where the second checkbox is the 18th instance of a checkbox in this particular form). But this specific coding, loaded into the action properties of the first checkbox doesn’t work in triggering the checking of the second, and I’m quite sure I’m doing something woefully wrong here. I'm not perfectly sure exactly what the zero-based item number (17 in the example above)--if someone could clarify that, it'd be a welcome bonus.

Has anyone done this very basic (I'd think common) bit of scripting? Can you lead me in the right direction?

Thanks!

Dale Davaz
da...@stcu.org

Nathan Strong

unread,
Sep 17, 2003, 10:46:31 AM9/17/03
to
A couple of different options:

You can make your "linked" checkbox checked by default, and then set an action on the first checkbox to show/hide the other field when it is checked. That avoids the whole JavaScript issue altogether.

The other option would be to go to the Actions tab of your first checkbox. Select "Mouse up" as the trigger, and "Run a JavaScript" as the action, then click Add.

This will give you the JavaScript editor, where you would put in the command to check the other field.

Of course, you probably want the actual JavaScript.. which I don't know offhand. But that's where you should be putting it! :)

Nathan

Dale Davaz

unread,
Sep 18, 2003, 11:43:51 AM9/18/03
to
Thanks, Nathan--the latter approach is the one in which I'm most interested.

If you (or anyone!) has a minute to give me a hand with the actual lines of scripting themselves, I'd sure appreciate it. My strong suspicion is that the checkThisBox method is at the center, but I'm having a devil of a time getting it in just the right form to work. Insights are definitely welcome!

Dale Davaz
da...@daledavaz.com
da...@stcu.org

Suzanne Cole

unread,
Sep 18, 2003, 1:48:47 PM9/18/03
to
Wish I could help--but I can at least provide a resource that is very quick to help with JavaScript questions, because they have a forum just for that purpose... <http://www.planetpdf.com> . You'll have to register to use the forums, but it's free and well worthwhile.

Nathan Strong

unread,
Sep 18, 2003, 1:52:27 PM9/18/03
to
Looking at the JS reference, you should be using 0 instead of 17 in your call to checkThisBox. The offset will only be greater than 0 if you are calling checkThisBox on a radio button, since the form field name is how radio buttons are grouped together.

Nathan

PDF Kid

unread,
Sep 19, 2003, 2:02:10 AM9/19/03
to
Alright - let me try with just 2 checkboxes...

PDF Kid

unread,
Sep 19, 2003, 3:17:59 AM9/19/03
to
Here is a sample -

<http://sedonainfotech.com/docc/CheckboxExample.pdf>

Let me know if it worked.

Manu.

Suzanne Cole

unread,
Sep 19, 2003, 12:01:28 PM9/19/03
to

>Let me know if it worked


Works beautifully for me (Acrobat 5.0.5, Win2K, IE 6.0).

PWhite

unread,
Sep 19, 2003, 1:07:34 PM9/19/03
to
I was working working on a similar project yesterday. Ran into a few problems initially but figured it out. Here are the lines. Please note. This is for three checkboxes that needed to be checked the same. Good luck.

// declare values for CheckBoxFirst (main) and CheckBoxSecond CheckBoxThird(dependent)

var f = this.getField("CheckBoxFirst");
var g = this.getField("CheckBoxSecond");
var h = this.getField("CheckBoxThird");

// test the field CheckBoxFirst to see if it is checked

if(f.isBoxChecked(0)) // 0 = the box is checked

g.checkThisBox(0,true); // true = check this box
else

g.checkThisBox(0,false); // false = don't check box

if(f.isBoxChecked(0)) // 0 = the box is checked

h.checkThisBox(0,true); // true = check this box
else

h.checkThisBox(0,false); // false = don't check box

Dale Davaz

unread,
Sep 19, 2003, 7:15:31 PM9/19/03
to
Thanks everyone! The solutions provided by both PDF Kid and PWhite give me two very robust approaches (similar in mechanics) that work splendidly. I'm very appreciative of your willingness to step in and assist! You're the best!

Dale Davaz

PDF Kid

unread,
Sep 20, 2003, 12:53:17 AM9/20/03
to
:-) Glad it worked for you.
0 new messages