XFA Specification
Chapter 9, Automation Objects
Document Variables
294
<field name="ShipDate" …>
<calculate>
<script>Num2Date(date() + 2, DateFmt())</script>
</calculate>
</field>
<field name="Total" …>
<calculate>
<script>Str(Sum(Amount[*]), 10, 2)</script>
</calculate>
</field>
</area>
</subform>
</template>
An explanation of the FormCalc expressions used in this sample is contained in the
“FormCalc
Specification” on page 801.
The scripts in calculations, validations and events may specify whether the script is to be executed at the
client, the server, or both.
See “Specifying Where to Execute a Script” on page 322.
Document Variables
Document variables may be used to hold boilerplate or image references that can be inserted
conditionally under control of a script or they may be used to define script object references.
Variables Used to Hold Boilerplate or Image References
For example, the terms and conditions of a purchase agreement can vary depending on some piece of
information entered in the form. Placing the boilerplate or image references into a
variables
element
makes it accessible to scripts via the usual mechanism of SOM expressions.
The variables element can hold any number of separate data items. The data items can be any kind of data.
Each data item bears its own name attribute so they are individually addressable by scripts. In SOM
expressions, data items are directly under the subform. The
variables
object is un-named, as described
in
“Variables Objects Are Always Transparent” on page 90.
As a result,
variables
objects are treated as a
transparent element in resolving SOM references.
Document variables may be read from or written to. That is, a document variable may be changed by the
form, perhaps as the result of an event script.
Example 9.1
results in an interface such as the one shown at right. If the
person filling in the form selects the button titled "Cat Lover," a picture of a
cat appears in the field above the selection, or if he/she selects the button
titled "Dog Lover," a picture of a dog appears. The value of the picture field
is a calculation that resolves to one of the variable children, depending on
the values of the exclusion group that contains the buttons. One of the
variables is a URL that references a cat image, and the other is a URL that
references a dog image.
Picture of
a cat or a
dog
Example 9.1
Button selection equates field with image variable
subform name="x">
<variables>
Home Index Bookmark Pages
Pages: Home Index All Pages