Using Acrobat JavaScript in Forms
Forms Essentials
6
Listbox Properties
A list box has many of the same properties as buttons and combo boxes, except for the fact
that the user may not enter custom text and, consequently, that spellchecking is not
available.
However, the user may select multiple entries. To enable this feature, set its
multipleSelection
property to
true
, as shown in the code below:
f.multipleSelection = true;
To set up an action associated with a selected item, invoke its
setAction
method and
pass in the
"Keystroke"
trigger name as the first parameter, as shown in the code below:
f.setAction( "Keystroke", "myListboxJavascript();" );
Radio Button Properties
The unique nature of radio buttons is that they are always created in sets, and represent a
collection of mutually exclusive choices. This means that when you create a set of radio
buttons, you must give all of them identical names and access them with zero-based
numeric indices, as you learned earlier in
Creating Acrobat Form Fields.
Radio buttons have many of the same properties as buttons and check boxes.
Signature Properties
Signature fields have many of the same properties as buttons. You may set the action of a
signature field by invoking its
setAction
method and passing in the
"Format"
trigger
name as the first parameter. When the user signs the form, you may reformat other form
fields with the script you pass into the
setAction
method.
Once a document is signed, you may wish to lock certain form fields within the document.
You may do so by creating a script containing a call to the signature field’s
setLock
method and passing that script as the second parameter to the signature field’s
setAction
method.
The
setLock
method requires a
Lock
object, which you will obtain by invoking the form
field’s
getLock
method. Once you obtain the
Lock
object, set its
action
and
fields
properties. The
action
property can be set to one of 3 values:
"All"
(lock all fields),
"exclude"
(lock all fields except for these), or
"include"
(lock only these fields). The
fields
property is an array of fields.
For example, suppose you created a signature and would like to lock the form field whose
name is
myField
after the user signs the document. The following code would lock
myField
:
var oLock = f.getLock();
oLock.action = "include";
oLock.fields = new Array("myField");
f.setLock(oLock);
To actually sign a document, you must do two things: choose a security handler, and then
invoke the signature field’s
signatureSign
method. The following code is an example of
how to choose a handler and actually sign the document:
Acrobat JavaScript Scripting Guide
99