Referencing Objects in Calculations and Scripts

Although both FormCalc calculations and JavaScript scripts have rules for structuring code, both rely on the same reference syntax when accessing form object properties and values. The XML Form Object Model provides a structured way to access object properties and values through a compound naming convention with each object, property, and method separated by dot (.) characters.

In general, each reference syntax has a similar structure divided into the following sections:

  • The names of the parent objects in the form hierarchy that is used to navigate to a specific field or object. You can use the Hierarchy palette and Data View palette to determine the location of an object relative to other objects in the form and in any associated data.

  • The name of the object you want to reference.

  • The the name of the property or method you want to access. This section may also include XML Form Object Model objects that precede the property or method in the structure but that do not appear as objects in the Hierarchy palette.

For example, the following illustration shows the reference syntax for accessing the value of a text field on a form design that uses the default object-naming conventions:

View full size graphic
A.
Form hierarchy objects

B.
Object name

C.
Property or method name

Note: By default, the subform object that represents the first page of a new form is unnamed. In the reference syntax above, the unnamed subform is represented by #subform.

The reference syntax notation structure varies slightly, depending on the specific situation. For example, a fully qualified reference syntax works in any situation; however, in some cases, you can use a shortened reference syntax or a reference syntax shortcut to reduce the size of the syntax.

// Ethnio survey code removed