1 function requestUpdate(url, fieldName, targetName, targetFieldName) { 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 // Find the value of the target field, along with the node where the target field is defined. 10 11 var targetFieldValue; 12 var targetFieldNodes = document.getElementsByName(targetFieldName); 13 if (targetFieldNodes.length != 0) { 14 targetFieldValue = targetFieldNodes[0].value; 15 } else { 16 targetFieldValue = ""; 17 } 18 19 // Load the remote document with the given parameters sent as text in the request body. 20 21 xmlhttp.send(fieldName + "=" + fieldValue + "\r\ntarget-field-name=" + targetFieldName + "\r\n" + targetFieldName + "=" + targetFieldValue); 22 23 // Parse the result document. 24 25 var newDocument = Sarissa.getDomDocument(); 26 newDocument.loadXML(xmlhttp.responseText); 27 28 // Find the definition of the affected field in the result document. 29 30 var newElement = newDocument.getElementById(targetName); 31 var targetElement = document.getElementById(targetName); 32 33 // Insert the new definition into the current document. 34 35 if (newElement != null && targetElement != null) { 36 var importedElement = document.importNode(newElement, true); 37 targetElement.parentNode.replaceChild(importedElement, targetElement); 38 //importedElement.setAttribute("style", "background-color:red;"); 39 } 40 }