Adobe acrobat forms javascript object specification 用户手册

下载
页码 64
Acrobat Forms - JavaScript Object Specification
58
var name = this.getfield("Name");
name.fillColor = color.yellow
When using this hierarchy within a JavaScript, remember you can only change appearance
related properties of the parent field and that appearance changes propagate to all children.
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";
Working With The Date Object
This section discusses the use of Date objects within Acrobat. The reader should be familiar
with the JavaScript Date object and the
functions that process dates. JavaScript Date
objects are actually an object containing both a date and time. All references to date in this
section refer to the date-time combination.
Note:
All date manipulations in JavaScript, including those methods that have
been documented in this specification are Year 2000 (Y2K) compliant.
Converting a Date to a String
Acrobat Forms provides several date related methods in addition to the ones provided by the
JavaScript Date object. These methods are the preferred method of converting between Date
objects and strings. Because of Acrobat Forms' ability to handle dates in many formats, the
Date object does not always handle these conversions correctly.
To convert a Date object into a string, the
method of the
is used. Unlike the
built-in conversion of the Date object to a string,
allows an exact specification of how
the date should be formatted.
/* Example of util.printd */
var d = new Date(); /* Create a Date object containing the current date. */
/* Create some strings from the Date object with various formats with
** util.printd */
var s1 = util.printd("mm/dd/yy", d);