SVFormXmlNodeChanged
JavaScript reference guides
JavaScript Wrappers
The SVFormXmlNodeChanged function is called upon the changing of a field.
Note: The SVFormXmlNodeChange function will not execute 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. |
changedFormElementId |
The internal identifier of the element that changed. The XPath to retrieve the SVXmlNode that changed is //*[@SVFormElementId=’" + changedFormElementId + ‘"] |
Code sampleThe following code snippet populates field2 with the text "The field has changed" upon execution of the function. If the argument xmlDocument is null, it displays an alert message saying ‘The xmlDocument was null!’: |
//SVFormXmlNodeChanged Example //Create function with the xmlDocument and changedFormElementId arguments function SVFormXmlNodeChanged(xmlDocument, changedFormElementId) { //Only execute code if the xmlDocument isn't null if (xmlDocument != null) { //Create a variable to place some text into (optional) var theField = xmlDocument.selectSingleNode("/my:myFields/my:field2"); //Set the variable theField to 'The field has changed!' theField.setValue("The field has changed!"); } else { //If the xmlDocument is null, return alert message. alert("The xmlDocument was null!"); } } //Create function with the xmlDocument and changedFormElementId arguments function SVFormXmlNodeChanged(xmlDocument, changedFormElementId) { //Only execute code if the xmlDocument isn't null if (xmlDocument != null) { var theXPath = "//*[@SVFormElementId='" + changedFormElementId + "']"; var theChangedNode = xmlDocument.selectSingleNode(theXPath); var theChangedNodeName = theChangedNode.getNodeName(); var theField = xmlDocument.selectSingleNode("/my:myFields/my:field2"); var num = theChangedNode.getValue(); if (num % 2 == 0) { //Set the variable theField to 'EVEN Number' theField.setValue("even"); } else { //Set the variable theField to 'EVEN Number' theField.setValue("odd"); } } else { //If the xmlDocument is null, return alert message. alert("The xmlDocument was null!"); } } |