# HG changeset patch # User paulb # Date 1121985514 0 # Node ID 23c09131ea2fd93a3bdb003daccf12fd0e166a30 # Parent a9f0b18c72a80a183612d702b99d62ac2a1b400f [project @ 2005-07-21 22:38:34 by paulb] Improved handling of missing target fields to permit such updates - this is useful when adding a section to a document. Added support for the collection and sending of multivalued select elements. diff -r a9f0b18c72a8 -r 23c09131ea2f examples/Common/Configurator/Resources/scripts/XSLForms.js --- a/examples/Common/Configurator/Resources/scripts/XSLForms.js Thu Jul 21 21:52:31 2005 +0000 +++ b/examples/Common/Configurator/Resources/scripts/XSLForms.js Thu Jul 21 22:38:34 2005 +0000 @@ -1,12 +1,5 @@ function requestUpdate(url, fieldNames, targetName, targetFieldNames, elementPath) { - // If no field names exist as targets for the update, do not attempt to - // update them. - - if (targetFieldNames == "") { - return; - } - // Note that XMLHttpRequest access may be denied if Mozilla believes that // this resource's URL and the supplied URL are different. @@ -51,6 +44,12 @@ function addFields(fieldNames, disable) { + // If no field names exist do not attempt to collect their values. + + if (fieldNames == "") { + return ""; + } + var requestBody = ""; // Process each target field name. @@ -67,8 +66,20 @@ var fieldValue; var fieldNodes = document.getElementsByName(fieldName); for (var v = 0; v < fieldNodes.length; v++) { - fieldValue = fieldNodes[v].value; - requestBody += ("\r\n" + fieldName + "=" + fieldValue); + + // Test for different field types. + + if (fieldNodes[v].options) { + for (var opt = 0; opt < fieldNodes[v].options.length; opt++) { + if (fieldNodes[v].options[opt].selected) { + fieldValue = fieldNodes[v].options[opt].value; + requestBody += ("\r\n" + fieldName + "=" + fieldValue); + } + } + } else { + fieldValue = fieldNodes[v].value; + requestBody += ("\r\n" + fieldName + "=" + fieldValue); + } } // NOTE: Konqueror hack: disable fields.