# HG changeset patch # User paulb # Date 1121971824 0 # Node ID d1df35a10de61f2d8f54c56264ffecbbc0c3d755 # Parent 46d1a3b13c96185f5e3eb07cea953928e6dbc9a2 [project @ 2005-07-21 18:50:24 by paulb] Permit multiple controlling field names and values. diff -r 46d1a3b13c96 -r d1df35a10de6 examples/Common/Configurator/Resources/scripts/XSLForms.js --- a/examples/Common/Configurator/Resources/scripts/XSLForms.js Thu Jul 21 18:49:50 2005 +0000 +++ b/examples/Common/Configurator/Resources/scripts/XSLForms.js Thu Jul 21 18:50:24 2005 +0000 @@ -1,4 +1,4 @@ -function requestUpdate(url, fieldName, targetName, targetFieldNames, elementPath) { +function requestUpdate(url, fieldNames, targetName, targetFieldNames, elementPath) { // If no field names exist as targets for the update, do not attempt to // update them. @@ -13,40 +13,14 @@ var xmlhttp = new XMLHttpRequest(); xmlhttp.open("POST", url, false); - // Find the value of the controlling field. + // Add the element path specification. - var fieldValue = document.getElementsByName(fieldName)[0].value; + var requestBody = ("element-path=" + elementPath); // Send the controlling field value. - var requestBody = (fieldName + "=" + fieldValue); - - // Process each target field name. - - var targetFieldNameArray = targetFieldNames.split(","); - - // Add the values of the dependent fields. - - for (var i = 0; i < targetFieldNameArray.length; i++) { - var targetFieldName = targetFieldNameArray[i]; - - // 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); - } - - // NOTE: Konqueror hack: disable fields. - - disableFields(targetFieldName); - } - - // Add the element path specification. - - requestBody += ("\r\nelement-path=" + elementPath); + requestBody += addFields(fieldNames, false); + requestBody += addFields(targetFieldNames, true); // Load the remote document with the given parameters sent as text in the request body. @@ -75,6 +49,38 @@ //showMismatch(targetFieldNameArray); } +function addFields(fieldNames, disable) { + + var requestBody = ""; + + // Process each target field name. + + var fieldNameArray = fieldNames.split(","); + + // Add the values of the dependent fields. + + for (var i = 0; i < fieldNameArray.length; i++) { + var fieldName = fieldNameArray[i]; + + // Find the values of the target field. + + var fieldValue; + var fieldNodes = document.getElementsByName(fieldName); + for (var v = 0; v < fieldNodes.length; v++) { + fieldValue = fieldNodes[v].value; + requestBody += ("\r\n" + fieldName + "=" + fieldValue); + } + + // NOTE: Konqueror hack: disable fields. + + if (disable) { + disableFields(fieldName); + } + } + + return requestBody; +} + function disableFields(targetFieldName) { for (var i = 0; i < document.forms.length; i++) {