Field Level; How Should I Name My Form Fields - Adobe 12001196 - Acrobat - Mac Manual

Javascript
Hide thumbs Also See for 12001196 - Acrobat - Mac:
Table of Contents

Advertisement

A Short Acrobat JavaScript FAQ
A
How should I name my form fields?
within the PDF document. Therefore, the forms programmer should make every effort to
package scripts as effectively as possible.
FDF programmers should also be aware that FDF files can include document-level scripts
and can also include scripts specified to be executed just before the FDF gets imported or
executed right after the FDF gets imported.

Field level

You can add scripts to a form field definition using a dialog box in the form editing tool.
These scripts are executed as the events occur (e.g. mouse up or calculate). Scripts that are
field specific should be created at this level. Usually these scripts validate, format, or
calculate field values.
Unlike plug-in folder scripts, document level and field level scripts are stored within the
PDF document and therefore the forms programmer should make every effort to package
his scripts as effectively as possible (e.g. code reuse) at the various levels for performance
and file size reasons.
How should I name my form fields?
Form fields typically have names like FirstName, LastName, etc. This naming convention
is referred to as flat names. For many form applications, this flat hierarchy of names is
sufficient and works well. The problem with using flat names is that there is no association
between the fields.
Form field names can be more useful by creating a hierarchal structure. For example, if we
change FirstName to Name.First and LastName to Name.Last we form a tree of fields.
The period (' . ' ) separator used in Acrobat Forms and denotes a hierarchy shift. The Name
portion of these fields is the parent, and First and Last become the children. While there
is no limit to the depth a hierarchical name can be constructed it is important that the
hierarchy remain manageable.
This hierarchy can be useful in a number of ways. It can speed up authoring and ease
manipulation of groups of fields in JavaScript. In addition, a form field hierarchy can
improve the performance of forms applications when there are many fields in the
document.
Using our original flat names FirstName, MiddleName and LastName, imagine that we
want to change the background color of these fields to yellow (to indicate missing data, or
emphasize an important point). We would need two lines of JavaScript code for each field:
var name = this.getField("FirstName");
name.fillColor = color.yellow;
name = this.getField("MiddleName");
name.fillColor = color.yellow;
name = this.getField("LastName");
name.fillColor = color.yellow;
76
Acrobat JavaScript Scripting Guide

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Acrobat 6.0

Table of Contents