6
Using Acrobat JavaScript in Forms
Forms Essentials
Checkbox Properties
The checkbox field supports many of the same properties as the button, and actions are
handled in the same manner. The properties common to bothform fields are:
●
●
●
●
●
●
●
●
●
●
userName
readonly
display
rotation
strokeColor
fillColor
lineWidth
borderStyle
textSize
textColor
In the case of
textFont
, however, the font is always set to
Adobe Pi
.
You may choose from six different glyph styles (the appearance of the check symbol that
appears when the user clicks in the check box):
check
(
style.ch
),
cross
(
style.cr
),
diamond
(
style.di
),
circle
(
style.ci
),
star
(
style.st
), and
square
(
style.sq
). For
example, the following code causes a check to appear when the user clicks in the check
box:
f.style = style.ch;
When the user selects a check box, an export value may be associated with the option
invoking the
field
object’s
setExportValues
property. For example, the code below
associates the export value
"buy"
with the check box:
f.setExportValues(["buy"]);
If there are several check box fields, you may wish to indicate that one particular form field
is always checked by default. To do this, you must do two things:
1.
Invoke the field’s
defaultIsChecked
method. Note that since there may be several
check boxes that belong to the same group, the method requires that you specify the
zero-based index of the particular check box.
2.
Reset the field to ensure that the default is applied by invoking the
doc
object’s
resetForm
method.
This process is shown in the following code:
f.defaultIsChecked(0); // 0 means that check box #0 is checked
this.resetForm([f.name]);
96
Acrobat JavaScript Scripting Guide