Help Center>Foundation Help

SVFormXMLChanged

The SVFormRowInserted function is targeted towards repeating elements (i.e., repeating table/repeating section). The SVFormRowInserted function is called after the insertion of a new row.

Note: The SVFormXmlChanged function will not run until after a value has been entered into a field and the field has left focus.

Argument

Description

xmlDocument

The SVXmlDocument containing the entire XML of the form.

XPath

The XPath to the newly inserted row.

Code sample

The following code snippet populates the first field in a repeating table with the current row number.

//SVFormRowInserted Example

//Create function with the xmlDocument and Xpath arguments

function SVFormRowInserted(xmlDocument, Xpath) {

//Create variable with XPath to the repeating element (optional)

var repeatingTableXPath = "/my:myFields/my:group1/my:group2";

//Create an array that stores all nodes within the repeating element (optional)

var repeatingTableNodes = xmlDocument.selectNodes(repeatingTableXPath);

//Create a for loop to cycle through all nodes within the repeating element (optional)

for (var i = 0; i < repeatingTableNodes.length; i++) {

//Create variable to set a value to (current row number) (optional)

var currentField = repeatingTableNodes[i].selectSingleNode(Xpath + "/my:field1");

//Set the variable to the number of the current row (optional)

currentField.setValue(i);

}

}