"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

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

From: Noa <nlevin@jacada.com>
Date: Wed Jan 25 2006 - 09:22:24 CET

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? is it a defined behavoiur?
And how can i get the name of the form ???
Received on Tue Feb 7 21:22:13 2006