You are here: Reference Guides > Javascript Support > SVFormRowInserted

SVFormRowInserted

The SVFormRowInserted function is targeted towards repeating elemtns (ie: repeating table/repeating section). The SVFormRowInserted function is called after the insertion of a new row.

Download example (.wssln file)

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

SVFormRowInserted arguments

Argument

Description

xmlDocument

The SVXmlDocument containing the entire XML of the form.

Xpath

The XPath to the newly inserted row.

SVFormRowInserted 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 nodees 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);

}

}