]> source.dussan.org Git - jquery.git/commitdiff
(no commit message)
authorGilles van den Hoven <gilles0181@gmail.com>
Thu, 1 Jun 2006 16:40:37 +0000 (16:40 +0000)
committerGilles van den Hoven <gilles0181@gmail.com>
Thu, 1 Jun 2006 16:40:37 +0000 (16:40 +0000)
ajax/ajax.js

index caa23e7765d4455c9b46b9b0e432580f1a904247..f7c858abbcb917e26e230a082767a840bda70359 100644 (file)
@@ -145,27 +145,36 @@ $.fn.formValues = function(sButton) {
 
        // Loop the shite
        $('*', this).each(function() {
+               // Skip disabled elements
+               if (this.disabled)
+                       return;
+
                // Skip elements not of the types in elp
                if (!elp[this.tagName.toUpperCase()])
                        return;
 
-               // Skip disabled elements, submit buttons and image buttons
-               if ((this.disabled) || (this.type == 'submit') || (this.type == 'image'))
+               // Skip submit buttons and image elements
+               if ((this.type == 'submit') || (this.type == 'image'))
                        return;
 
-               // Skip non-selected nodes
-               if ((this.parentNode.nodeName == 'SELECT') && (!this.selected))
+
+               // Skip non-selected options
+               var sP = this.parentNode.nodeName.toUpperCase();
+               if (((sP == 'SELECT') || (sP == 'OPTGROUP')) && (!this.selected))
                        return;
 
                // Skip non-checked nodes
                if (((this.type == 'radio') || (this.type == 'checkbox')) && (!this.checked))
                        return;
 
-               // If we come here, everything is fine, so add the data
-               a.push({
-                       name: this.name || this.id || this.parentNode.name || this.parentNode.id,
-                       value: this.value
-               });
+               // If we come here, everything is fine
+               var sN = this.name || this.id || this.parentNode.name || this.parentNode.id;
+               var sV = this.value;
+               if ((!sN) && (sP == 'OPTGROUP'))
+                       sN = this.parentNode.parentNode.name || this.parentNode.parentNode.id;
+
+               // Add the data
+               a.push({ name: sN, value: sV });
        });
 
        // Add submit button if needed