# HG changeset patch # User paulb # Date 1115590138 0 # Node ID 92add8fcb2f29db9378486b4d556711acfb28ede # Parent c2d72da6df2d662c93e72bc626ea0d50bd828a00 [project @ 2005-05-08 22:08:58 by paulb] Added support for multiple field names and values. diff -r c2d72da6df2d -r 92add8fcb2f2 examples/Common/Configurator/Resources/scripts/XSLForms.js --- a/examples/Common/Configurator/Resources/scripts/XSLForms.js Sun May 08 22:08:32 2005 +0000 +++ b/examples/Common/Configurator/Resources/scripts/XSLForms.js Sun May 08 22:08:58 2005 +0000 @@ -1,4 +1,4 @@ -function requestUpdate(url, fieldName, targetName, targetFieldName) { +function requestUpdate(url, fieldName, targetName, targetFieldNames) { var xmlhttp = Sarissa.getXmlHttpRequest(); xmlhttp.open("POST", url, false); @@ -6,19 +6,36 @@ var fieldValue = document.getElementsByName(fieldName)[0].value; - // Find the value of the target field, along with the node where the target field is defined. + // Process each target field name. + + var targetFieldNameArray = targetFieldNames.split(","); + + // Send the controlling field value. + + var requestBody = (fieldName + "=" + fieldValue); + + // Add the values of the dependent fields. + + for (var i = 0; i < targetFieldNameArray.length; i++) { + var targetFieldName = targetFieldNameArray[i]; - var targetFieldValue; - var targetFieldNodes = document.getElementsByName(targetFieldName); - if (targetFieldNodes.length != 0) { - targetFieldValue = targetFieldNodes[0].value; - } else { - targetFieldValue = ""; + // Find the values of the target field. + + var targetFieldValue; + var targetFieldNodes = document.getElementsByName(targetFieldName); + for (var v = 0; v < targetFieldNodes.length; v++) { + targetFieldValue = targetFieldNodes[v].value; + requestBody += ("\r\n" + targetFieldName + "=" + targetFieldValue); + } + + // Add the target name specification. + + requestBody += ("\r\ntarget-field-name=" + targetFieldName); } // 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); + xmlhttp.send(requestBody); // Parse the result document.