Adobe acrobat forms javascript object specification User Manual

Page of 64
Acrobat Forms - JavaScript Object Specification
48
This function returns an array of terminal children fields (i.e. fields that can have a value) for a
parent field. This method can be particularly useful for doing field calculations in tables where
a parent field value is the sum of all of its children. To understand more about field name and
hierarchies, please see the section on
.
// f has 3 children: f.v1, f.v2, f.v3
var f = this.getField("f");
var a = f.getArray();
var v = 0.0;
for (j =0; j < a.length; j++)
v += a[j].value;
// v contains the sum of all the children of field "f"
getItemAt
Parameters: nIndex
Returns: 
internal value in an item in a list or combo box
This function gets the internal value of an item in a combo box or a list box. The parameter
nIndex is the index of the item in the list to obtain. If nIndex is set to -1, it returns the value of
the last item in the list. The getItemAt function returns the exported or internal value of the
item at nIndex in the combo box or list box.
// returns value of first item in list l
var a = this.getField("MyListBox");
var v = a.getItemAt(0);
insertItemAt
Parameters: cName, cExportValue, [nIndex]
Returns: nothing
This function inserts a new item into a combo box or a list box. cName is the index at which to
insert the item in a list box or combo box. cExportValue is the string export value of the item
i.e. internal value of the item being inserted. nIndex is the index in the list to insert the item at.
If nIndex is 0, cName is inserted at the top of the list. If nIndex is –1, cName is inserted at the
end of the list. The default value for nIndex is 0.
var l = this.getField("l"); /* l is a list box */
var v =l.insertItemAt("sam", "s", 0); /* inserts sam to top of list l */
setItems
Parameters: array
4.0