(no commit message)
[jquery.git] / ajax / ajax.js
index 6339f7d..f7c858a 100644 (file)
@@ -145,33 +145,48 @@ $.fn.formValues = function(sButton) {
 
        // Loop the shite
        $('*', this).each(function() {
-               // Skip elements not of the types in elp
-               if (!elp[this.tagName])
-                       return;
-
                // Skip disabled elements
                if (this.disabled)
                        return;
 
-               // Skip non-selected nodes
-               if ((this.parentNode.nodeName == 'SELECT') && (!this.selected))
+               // Skip elements not of the types in elp
+               if (!elp[this.tagName.toUpperCase()])
+                       return;
+
+               // Skip submit buttons and image elements
+               if ((this.type == 'submit') || (this.type == 'image'))
+                       return;
+
+
+               // 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
-       if (sButton && (sButton !== null))
-               a.push({ name: sButton, value: 'x' });
+       if (sButton && (sButton !== null)) {
+               var el = $(sButton).get(0);
+               a.push({
+                       name: el.name || el.id || el.parentNode.name || el.parentNode.id,
+                       value: el.value
+               });
+       }
 
+       // Done
        return a;
 };