1 function requestUpdate(url, fieldName, targetName, targetFieldNames) { 2 var xmlhttp = Sarissa.getXmlHttpRequest(); 3 xmlhttp.open("POST", url, false); 4 5 // Find the value of the controlling field. 6 7 var fieldValue = document.getElementsByName(fieldName)[0].value; 8 9 // Process each target field name. 10 11 var targetFieldNameArray = targetFieldNames.split(","); 12 13 // Send the controlling field value. 14 15 var requestBody = (fieldName + "=" + fieldValue); 16 17 // Add the values of the dependent fields. 18 19 for (var i = 0; i < targetFieldNameArray.length; i++) { 20 var targetFieldName = targetFieldNameArray[i]; 21 22 // Find the values of the target field. 23 24 var targetFieldValue; 25 var targetFieldNodes = document.getElementsByName(targetFieldName); 26 for (var v = 0; v < targetFieldNodes.length; v++) { 27 targetFieldValue = targetFieldNodes[v].value; 28 requestBody += ("\r\n" + targetFieldName + "=" + targetFieldValue); 29 } 30 31 // Add the target name specification. 32 33 requestBody += ("\r\ntarget-field-name=" + targetFieldName); 34 } 35 36 // Load the remote document with the given parameters sent as text in the request body. 37 38 xmlhttp.send(requestBody); 39 40 // Parse the result document. 41 42 var newDocument = Sarissa.getDomDocument(); 43 newDocument.loadXML(xmlhttp.responseText); 44 45 // Find the definition of the affected field in the result document. 46 47 var newElement = newDocument.getElementById(targetName); 48 var targetElement = document.getElementById(targetName); 49 50 // Insert the new definition into the current document. 51 52 if (newElement != null && targetElement != null) { 53 var importedElement = document.importNode(newElement, true); 54 targetElement.parentNode.replaceChild(importedElement, targetElement); 55 //importedElement.setAttribute("style", "background-color:red;"); 56 } 57 }