Re: "getAttribute" returns a child element instead of ...?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: "getAttribute" returns a child element instead of ...?

From: VK <schools_ring@yahoo.com>
Date: Wed Jan 25 2006 - 11:28:09 CET

Noa wrote:
> Hi
>
> I have a page that looks like that:
>
> <form name="kuku1" action ="anotherpage.html" >
> <input name="name">
> <input name="kuku2">
> </form>
>
> As far as i know, "getAttribute" should return a string value of an
> elements' attribute.
>
> document.forms[0].getAttribute("action") indeed returns the string
> "anotherpage.html"
> document.forms[0].action will also return that string
>
> However, document.forms[0].getAttribute("name") does not return the
> string "kuku1", but it returns the first input object.
> In a similar way , document.forms[0].getAttribute("kuku2") returns the
> second input element, and not a null object (or an empty string) as i
> would expect.
>
> Is it a bug?

No, just wrong usage of right tools. Drop it for now.

> And how can i get the name of the form ???

alert(document.forms[0].name);
alert(document.forms[0].action);
alert(document.forms[0].method);
alert(document.forms[0].enctype);

alert(document.forms[0].elements[0].name);
alert(document.forms[0].elements[1].name);
....
Received on Tue Feb 7 21:22:21 2006