# HG changeset patch # User paulb # Date 1115586324 0 # Node ID d782f2178752fb196df532ddf50052853f63f1ad # Parent 7dd59143b25aff2689d637d65179d29924dc0400 [project @ 2005-05-08 21:05:24 by paulb] Added some comments to explain the workings of the script function. diff -r 7dd59143b25a -r d782f2178752 examples/Common/Configurator/Resources/scripts/XSLForms.js --- a/examples/Common/Configurator/Resources/scripts/XSLForms.js Sat May 07 00:45:09 2005 +0000 +++ b/examples/Common/Configurator/Resources/scripts/XSLForms.js Sun May 08 21:05:24 2005 +0000 @@ -1,7 +1,13 @@ function requestUpdate(url, fieldName, targetName, targetFieldName) { var xmlhttp = Sarissa.getXmlHttpRequest(); xmlhttp.open("POST", url, false); + + // Find the value of the controlling field. + var fieldValue = document.getElementsByName(fieldName)[0].value; + + // Find the value of the target field, along with the node where the target field is defined. + var targetFieldValue; var targetFieldNodes = document.getElementsByName(targetFieldName); if (targetFieldNodes.length != 0) { @@ -9,17 +15,22 @@ } else { targetFieldValue = ""; } - //alert(fieldValue); + + // Load the remote document with the given parameters sent as text in the request body. + xmlhttp.send(fieldName + "=" + fieldValue + "\r\ntarget-field-name=" + targetFieldName + "\r\n" + targetFieldName + "=" + targetFieldValue); - //alert(xmlhttp.status); - //alert(xmlhttp.responseText); + + // Parse the result document. + var newDocument = Sarissa.getDomDocument(); newDocument.loadXML(xmlhttp.responseText); - //alert(newDocument); + + // Find the definition of the affected field in the result document. + var newElement = newDocument.getElementById(targetName); var targetElement = document.getElementById(targetName); - //alert(newElement); - //alert(targetElement); + + // Insert the new definition into the current document. if (newElement != null && targetElement != null) { var importedElement = document.importNode(newElement, true);