Re: Accessing Form attributes instead of elements

Thomas Fuchs
Sat, 22 Sep 2007 11:58:42 -0000

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
> >