XSLTools

Changeset

170:23c09131ea2f
2005-07-21 paulb raw files shortlog changelog graph [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.
examples/Common/Configurator/Resources/scripts/XSLForms.js (file)
     1.1 --- a/examples/Common/Configurator/Resources/scripts/XSLForms.js	Thu Jul 21 21:52:31 2005 +0000
     1.2 +++ b/examples/Common/Configurator/Resources/scripts/XSLForms.js	Thu Jul 21 22:38:34 2005 +0000
     1.3 @@ -1,12 +1,5 @@
     1.4  function requestUpdate(url, fieldNames, targetName, targetFieldNames, elementPath) {
     1.5  
     1.6 -    // If no field names exist as targets for the update, do not attempt to
     1.7 -    // update them.
     1.8 -
     1.9 -    if (targetFieldNames == "") {
    1.10 -        return;
    1.11 -    }
    1.12 -
    1.13      // Note that XMLHttpRequest access may be denied if Mozilla believes that
    1.14      // this resource's URL and the supplied URL are different.
    1.15  
    1.16 @@ -51,6 +44,12 @@
    1.17  
    1.18  function addFields(fieldNames, disable) {
    1.19  
    1.20 +    // If no field names exist do not attempt to collect their values.
    1.21 +
    1.22 +    if (fieldNames == "") {
    1.23 +        return "";
    1.24 +    }
    1.25 +
    1.26      var requestBody = "";
    1.27  
    1.28      // Process each target field name.
    1.29 @@ -67,8 +66,20 @@
    1.30          var fieldValue;
    1.31          var fieldNodes = document.getElementsByName(fieldName);
    1.32          for (var v = 0; v < fieldNodes.length; v++) {
    1.33 -            fieldValue = fieldNodes[v].value;
    1.34 -            requestBody += ("\r\n" + fieldName + "=" + fieldValue);
    1.35 +
    1.36 +            // Test for different field types.
    1.37 +
    1.38 +            if (fieldNodes[v].options) {
    1.39 +                for (var opt = 0; opt < fieldNodes[v].options.length; opt++) {
    1.40 +                    if (fieldNodes[v].options[opt].selected) {
    1.41 +                        fieldValue = fieldNodes[v].options[opt].value;
    1.42 +                        requestBody += ("\r\n" + fieldName + "=" + fieldValue);
    1.43 +                    }
    1.44 +                }
    1.45 +            } else {
    1.46 +                fieldValue = fieldNodes[v].value;
    1.47 +                requestBody += ("\r\n" + fieldName + "=" + fieldValue);
    1.48 +            }
    1.49          }
    1.50  
    1.51          // NOTE: Konqueror hack: disable fields.