A
A Short Acrobat JavaScript FAQ
How should I name my Acrobat form fields?
With the hierarchy of
Name
.
First
,
Name
.
Middle
and
Name
.
Last
suggested above,
you can change the background color of these fields with just two lines of code instead of
six:
var name = this.getfield("Name");
name.fillColor = color.yellow
When using this hierarchy within a JavaScript, you can only change appearance-related
properties of the parent field, and those changes will propagate to all its children. However,
you cannot change the field’s value. For example if you try the following script:
var name = this.getField("Name");
name.value = "Lincoln";
the script will fail.
Name
is considered a parent field. You can only change the value of
terminal fields (i.e. a field that does not have children like
Last
or
First
). The following
script executes correctly:
var first = this.getField("Name.First");
var last = this.getField("Name.Last");
first.value = "Abraham";
last.value = "Lincoln";
262
Acrobat JavaScript Scripting Guide