Jean-Philippe Encausse
2007-Sep-20 10:04 UTC
[Off-Topic] Accessing Form attributes instead of elements
Hi, I''m sorry for this JavaScript Off topic question a little bit tricky: I have an HML Form with: - An input using name="name" - An attibute name="formName" In JavaScript I would like to access the form''s attribute. How to do that ? - form.name returns input - form[''name''] returns input Any idea ? Best regards and sorry for the off topic -- Jean-Philippe Encausse - Veille / R&D Jalios SA Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 18 90 15 Do it Once, Use it Twice ~ Do it Twice, Make It Once --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
isn''t that what the readAttribute method is for? form.readAttribute(''name''); On Sep 20, 12:04 pm, "Jean-Philippe Encausse" <J...-vcK5r0oTKUrk1uMJSBkQmQ@public.gmane.org> wrote:> Hi, > > I''m sorry for this JavaScript Off topic question a little bit tricky: > > I have an HML Form with: > - An input using name="name" > - An attibute name="formName" > > In JavaScript I would like to access the form''s attribute. How to do that ? > > - form.name returns input > - form[''name''] returns input > > Any idea ? > Best regards and sorry for the off topic > > -- > Jean-Philippe Encausse - Veille / R&D Jalios SA > Jp [at] encausse.net -http://www.encausse.com-http://www.jalias.com > GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net > Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 18 90 15 > Do it Once, Use it Twice ~ Do it Twice, Make It Once--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Jean-Philippe Encausse
2007-Sep-21 07:11 UTC
Re: Accessing Form attributes instead of elements
I didn''t knew this method ? I find a solution: I did form.attributes[''name''].value it works on IE and FF On 9/21/07, Wizz <woutawizz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > isn''t that what the readAttribute method is for? > > form.readAttribute(''name''); > > On Sep 20, 12:04 pm, "Jean-Philippe Encausse" <J...-vcK5r0oTKUrk1uMJSBkQmQ@public.gmane.org> > wrote: > > Hi, > > > > I''m sorry for this JavaScript Off topic question a little bit tricky: > > > > I have an HML Form with: > > - An input using name="name" > > - An attibute name="formName" > > > > In JavaScript I would like to access the form''s attribute. How to do that ? > > > > - form.name returns input > > - form[''name''] returns input > > > > Any idea ? > > Best regards and sorry for the off topic > > > > -- > > Jean-Philippe Encausse - Veille / R&D Jalios SA > > Jp [at] encausse.net -http://www.encausse.com-http://www.jalias.com > > GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net > > Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 18 90 15 > > Do it Once, Use it Twice ~ Do it Twice, Make It Once > > > > >-- Jean-Philippe Encausse - Veille / R&D Jalios SA Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 18 90 15 Do it Once, Use it Twice ~ Do it Twice, Make It Once --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
getAttribute Method Internet Development Index<mk:@MSITStore:D:\My%20Documents\电脑技术文档\HTML\DHTML%20手册.chm::/DHTMLref/default.html> ------------------------------ Retrieves the value of the specified attribute. Syntax *vAttrValue* = *object**.getAttribute(**sAttrName** [**, **iFlags**]**)* Parameters *sAttrName* Required. *String* that specifies the name of the attribute. * iFlags* Optional. *Integer* that specifies one or more of the following flags: 0 Default. Performs a property search that is not case-sensitive, and returns an interpolated value if the property is found. 1 Performs a case-sensitive property search. To find a match, the uppercase and lowercase letters in *sAttrName *must exactly match those in the attribute name. If the *iFlags *parameter for *getAttribute* is set to 1 and this option is set to 0 (default), the specified property name might not be found. 2 Returns the value exactly as it was set in script or in the source document. Return Value *Variant* that returns a *String*, number, or *Boolean* value as defined by the attribute. If the attribute is not present, this method returns null. Remarks If two or more attributes have the same name (differing only in uppercase and lowercase letters) and *iFlags *is 0, the *getAttribute* method retrieves values only for the last attribute created with this name, and ignores all other attributes with the same name. When retrieving the CLASS<mk:@MSITStore:D:\My%20Documents\电脑技术文档\HTML\DHTML%20手册.chm::/DHTMLref/properties/classname.html>attribute using this method, set the *sAttrName *to be "className", which is the corresponding Dynamic HTML (DHTML) property. This method is used only by events created from HTML Components. Standards Information This method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 <http://www.w3.org/tr/2000/wd-dom-level-1-20000929/> [image: Non-Microsoft link]. 2007/9/21, Jean-Philippe Encausse <Jp@encausse.net>:> > > I didn't knew this method ? > I find a solution: I did form.attributes['name'].value it works on IE and > FF > > > On 9/21/07, Wizz <woutawizz@gmail.com> wrote: > > > > isn't that what the readAttribute method is for? > > > > form.readAttribute('name'); > > > > On Sep 20, 12:04 pm, "Jean-Philippe Encausse" <J...@encausse.net> > > wrote: > > > Hi, > > > > > > I'm sorry for this JavaScript Off topic question a little bit tricky: > > > > > > I have an HML Form with: > > > - An input using name="name" > > > - An attibute name="formName" > > > > > > In JavaScript I would like to access the form's attribute. How to do > that ? > > > > > > - form.name returns input > > > - form['name'] returns input > > > > > > Any idea ? > > > Best regards and sorry for the off topic > > > > > > -- > > > Jean-Philippe Encausse - Veille / R&D Jalios SA > > > Jp [at] encausse.net -http://www.encausse.com-http://www.jalias.com > > > GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net > > > Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 18 90 > 15 > > > Do it Once, Use it Twice ~ Do it Twice, Make It Once > > > > > > > > > > > > -- > Jean-Philippe Encausse - Veille / R&D Jalios SA > Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com > GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net > Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 18 90 15 > Do it Once, Use it Twice ~ Do it Twice, Make It Once > > > >-- Hambo szhambo@gmail.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 20, 8:04 pm, "Jean-Philippe Encausse" <J...-vcK5r0oTKUrk1uMJSBkQmQ@public.gmane.org> wrote:> Hi, > > I''m sorry for this JavaScript Off topic question a little bit tricky: > > I have an HML Form with: > - An input using name="name" > - An attibute name="formName" > > In JavaScript I would like to access the form''s attribute. How to do that ? > > - form.name returns input > - form[''name''] returns input > > Any idea ?The attributes of HTML elements can be accessed as properties of the DOM HTML object that represents the element using dot properties or square bracket notation. HTML DOM forms have an elements collection that contains all the controls within the form. It is a convention that each member of that collection that has a name can be accessed as a property of the form DOM object itself. The result is that where a form control has a name that is the same as an attribute of the formelement, the form''s dot property accessor will be a reference to the form control, not the native attribute of the form. The most common incarnation of this is when a submit button named "submit" is placed in a form, thereby shadowing the form''s submit method. Attempting to call the form''s submit method results in a javascript error. The W3C DOM Core getAttribute method *should* access the actual properties of the form, so: $(formID).getAttribute(''name'') *should* do the job. However, IE''s getAttribute method is broken in places, so an alternative is to use the HTML Element''s attributes object: $(formID).attributes.getNamedItem(''name'').nodeValue which *should* work in any W3C DOM 2 conforming browser. Unfortunately, IE is again deficient. While the above does work, an appropriate feature test would be: var el = $(formID); if (typeof el.attributes == ''object'' && typeof el.attributes.getNamedItem == ''function'') { return el.attributes.getNamedItem(attributeName).nodeValue; } but in the second part of the test, IE returns ''object'', not ''function''. So the test becomes: if (typeof el.attributes == ''object'' && (typeof el.attributes.getNamedItem == ''function'' || typeof el.attributes.getNamedItem == ''object'') ) { ... } So there is still a chance (however unlikely) that it will fall apart because getNamedItem has been replaced by an object and is not a function. Another aspect is that the attributes are also available as properties of the attributes object itself, so: $(formID).attributes[''name''].nodeValue "works". That is what Prototype.js uses for its readAttribute method - but only where its browser sniffing says it is working with IE, in other cases it will use getAttribute. It think the feature test above is a more robust solution than browser sniffing, even though it is not perfect. In any case, it is best if you never create form controls with names that match native attributes of the form DOM object so that you can rely on the tried-and-true dot property access method. -- Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Consider using Prototype''s readAttribute method instead. It automatically deals with cross-browser stupidities, which there are quite a few of. http://prototypejs.org/api/element/readattribute Best, Thomas Am 21.09.2007 um 09:46 schrieb Hambo:> getAttribute Method Internet Development Index > Retrieves the value of the specified attribute. > > Syntax > > vAttrValue = object.getAttribute(sAttrName [, iFlags] ) > Parameters > > sAttrNameRequired. String that specifies the name of the attribute. > iFlagsOptional. Integer that specifies one or more of the following > flags: > 0Default. Performs a property search that is not case-sensitive, > and returns an interpolated value if the property is found. > 1Performs a case-sensitive property search. To find a match, the > uppercase and lowercase letters in sAttrName must exactly match > those in the attribute name. If the iFlags parameter for > getAttribute is set to 1 and this option is set to 0 (default), the > specified property name might not be found. > 2Returns the value exactly as it was set in script or in the source > document. > Return Value > > Variant that returns a String, number, or Boolean value as defined > by the attribute. If the attribute is not present, this method > returns null. > > Remarks > > If two or more attributes have the same name (differing only in > uppercase and lowercase letters) and iFlags is 0, the getAttribute > method retrieves values only for the last attribute created with > this name, and ignores all other attributes with the same name. > > When retrieving the CLASS attribute using this method, set the > sAttrName to be "className", which is the corresponding Dynamic > HTML (DHTML) property. > > This method is used only by events created from HTML Components. > > Standards Information > > This method is defined in World Wide Web Consortium (W3C) Document > Object Model (DOM) Level 1 . > > > > 2007/9/21, Jean-Philippe Encausse <Jp-vcK5r0oTKUrk1uMJSBkQmQ@public.gmane.org>: > I didn''t knew this method ? > I find a solution: I did form.attributes[''name''].value it works on > IE and FF > > > On 9/21/07, Wizz <woutawizz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > isn''t that what the readAttribute method is for? > > > > form.readAttribute(''name''); > > > > On Sep 20, 12:04 pm, "Jean-Philippe Encausse" <J...-vcK5r0oTKUrk1uMJSBkQmQ@public.gmane.org> > > wrote: > > > Hi, > > > > > > I''m sorry for this JavaScript Off topic question a little bit > tricky: > > > > > > I have an HML Form with: > > > - An input using name="name" > > > - An attibute name="formName" > > > > > > In JavaScript I would like to access the form''s attribute. How > to do that ? > > > > > > - form.name returns input > > > - form[''name''] returns input > > > > > > Any idea ? > > > Best regards and sorry for the off topic > > > > > > -- > > > Jean-Philippe Encausse - Veille / R&D Jalios SA > > > Jp [at] encausse.net -http://www.encausse.com-http:// > www.jalias.com > > > GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net > > > Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 > 18 90 15 > > > Do it Once, Use it Twice ~ Do it Twice, Make It Once > > > > > > > > > > > > -- > Jean-Philippe Encausse - Veille / R&D Jalios SA > Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com > GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net > Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 18 > 90 15 > Do it Once, Use it Twice ~ Do it Twice, Make It Once > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Consider using Prototype''s readAttribute method instead. It automatically deals with cross-browser stupidities, which there are quite a few of. http://prototypejs.org/api/element/readattribute Best, Thomas Am 21.09.2007 um 09:46 schrieb Hambo:> getAttribute Method Internet Development Index > Retrieves the value of the specified attribute. > > Syntax > > vAttrValue = object.getAttribute(sAttrName [, iFlags] ) > Parameters > > sAttrNameRequired. String that specifies the name of the attribute. > iFlagsOptional. Integer that specifies one or more of the following > flags: > 0Default. Performs a property search that is not case-sensitive, > and returns an interpolated value if the property is found. > 1Performs a case-sensitive property search. To find a match, the > uppercase and lowercase letters in sAttrName must exactly match > those in the attribute name. If the iFlags parameter for > getAttribute is set to 1 and this option is set to 0 (default), the > specified property name might not be found. > 2Returns the value exactly as it was set in script or in the source > document. > Return Value > > Variant that returns a String, number, or Boolean value as defined > by the attribute. If the attribute is not present, this method > returns null. > > Remarks > > If two or more attributes have the same name (differing only in > uppercase and lowercase letters) and iFlags is 0, the getAttribute > method retrieves values only for the last attribute created with > this name, and ignores all other attributes with the same name. > > When retrieving the CLASS attribute using this method, set the > sAttrName to be "className", which is the corresponding Dynamic > HTML (DHTML) property. > > This method is used only by events created from HTML Components. > > Standards Information > > This method is defined in World Wide Web Consortium (W3C) Document > Object Model (DOM) Level 1 . > > > > 2007/9/21, Jean-Philippe Encausse <Jp-vcK5r0oTKUrk1uMJSBkQmQ@public.gmane.org>: > I didn''t knew this method ? > I find a solution: I did form.attributes[''name''].value it works on > IE and FF > > > On 9/21/07, Wizz <woutawizz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > isn''t that what the readAttribute method is for? > > > > form.readAttribute(''name''); > > > > On Sep 20, 12:04 pm, "Jean-Philippe Encausse" <J...-vcK5r0oTKUrk1uMJSBkQmQ@public.gmane.org> > > wrote: > > > Hi, > > > > > > I''m sorry for this JavaScript Off topic question a little bit > tricky: > > > > > > I have an HML Form with: > > > - An input using name="name" > > > - An attibute name="formName" > > > > > > In JavaScript I would like to access the form''s attribute. How > to do that ? > > > > > > - form.name returns input > > > - form[''name''] returns input > > > > > > Any idea ? > > > Best regards and sorry for the off topic > > > > > > -- > > > Jean-Philippe Encausse - Veille / R&D Jalios SA > > > Jp [at] encausse.net -http://www.encausse.com-http:// > www.jalias.com > > > GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net > > > Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 > 18 90 15 > > > Do it Once, Use it Twice ~ Do it Twice, Make It Once > > > > > > > > > > > > -- > Jean-Philippe Encausse - Veille / R&D Jalios SA > Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com > GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net > Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 18 > 90 15 > Do it Once, Use it Twice ~ Do it Twice, Make It Once > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 22, 6:55 pm, Thomas Fuchs <tho...-9D208sng4xU@public.gmane.org> wrote:> Consider using Prototype''s readAttribute method instead. It > automatically deals with cross-browser stupiditiesreadAttribute has its problems too. Where an attribute value is expected to be a string and has not been specified at all, IE returns an empty string, other browsers return null. So in IE you can''t tell whether the attribute was not specified (which should return null), or was specified and not given a value (which should return an empty string). As far as I know, the only way to fix that in IE is to parse the element''s HTML to determine the correct response. Also, when using readAttribute with the checked attribute and it has been set, IE returns ''checked'', Firefox returns an empty string. So there are quite a few foibles that readAttribute does not deal with. -- Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Seems that these are bugs. Can you whip up some failing unit tests for this? best, thomas Am 24.09.2007 um 05:12 schrieb RobG:> > > > On Sep 22, 6:55 pm, Thomas Fuchs <tho...-9D208sng4xU@public.gmane.org> wrote: >> Consider using Prototype''s readAttribute method instead. It >> automatically deals with cross-browser stupidities > > readAttribute has its problems too. Where an attribute value is > expected to be a string and has not been specified at all, IE returns > an empty string, other browsers return null. So in IE you can''t tell > whether the attribute was not specified (which should return null), or > was specified and not given a value (which should return an empty > string). > > As far as I know, the only way to fix that in IE is to parse the > element''s HTML to determine the correct response. > > Also, when using readAttribute with the checked attribute and it has > been set, IE returns ''checked'', Firefox returns an empty string. > > So there are quite a few foibles that readAttribute does not deal > with. > > > -- > Rob > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Jean-Philippe Encausse
2007-Sep-24 08:19 UTC
Re: Accessing Form attributes instead of elements
Great I was looking for that but didn''t find it. Thanks ! According to http://www.quirksmode.org/dom/w3c_core.html => getAttribute() It seems to be a big mess ...> Consider using Prototype''s readAttribute method instead. It > automatically deals with cross-browser stupidities, which there are > quite a few of.> http://prototypejs.org/api/element/readattribute> Best, > Thomas-- Jean-Philippe Encausse - Veille / R&D Jalios SA Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 18 90 15 Do it Once, Use it Twice ~ Do it Twice, Make It Once --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 24, 5:33 pm, Thomas Fuchs <tho...-9D208sng4xU@public.gmane.org> wrote:> Seems that these are bugs. Can you whip up some failing unit tests > for this?I stand corrected on the checked attribute, when it is not set on IE readAttribute returns null, as it should. However when set, IE returns ''checked'' whereas other browsers return an empty string. The significance that will vary, but is likely more significant when serialising forms. For those attributes that return a boolean (checked, selected, readonly, etc.), it is better to use dot properties ($(id).checked which seems to return a boolean in all browsers) rather than attempt to use either getAttribute or the attributes object. Anyhow, as for test cases, any attribute that takes a string value should do - name, id, value... <form id="f0"> <input type="checkbox" id="i0" name=""> <input type="checkbox" id="i1"> <input type="checkbox" id="i2" checked> <input type="text" id="i3"> <input type="text" id="i4" value=""> </form> <script> var t = []; [ [''f0'',''name''],[''i0'',''name''] ,[''i1'',''checked''],[''i2'',''checked''] ,[''i3'',''value''],[''i4'',''value''] ].each(function (a){ var x = $(a[0]).readAttribute(a[1]); t.push( a[1] + '': '' + typeof x + '' : '' + x); }); alert(t.join(''\n'')); </script> -- Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---