Forum Moderators: open

Message Too Old, No Replies

document.GetElementById has no properties

document.GetElementById has no properties

         

kiden

4:18 pm on Jan 30, 2008 (gmt 0)

10+ Year Member



Hi

I can only think I'm being really silly here, but why doesn't this work..?

<html>
<head>
<script>
function read_it() {
alert("hello"); //works
alert(document.GetElementById['bob'].innerHTML); //returns 'has no properties' in FF error console
}
</script>
</head>
<body>
<div id="bob"><p>this is some text</p></div>
<input type="submit" value="click" onclick="read_it()" />
</body>

Thanks!

Fotiman

4:26 pm on Jan 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



JavaScript is case sensitive.
document.GetElementById
should be
document.getElementById

(lowercase on the 'g')

kiden

4:28 pm on Jan 30, 2008 (gmt 0)

10+ Year Member



thanks for replying :) but... correcting the typo (silly mistake - doh!) hasn't fixed it :(

Dabrowski

5:05 pm on Jan 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your syntax is wrong.....

alert(document.getElementById('bob').innerHTML);

They should be curly brackets, not square.

birdbrain

5:55 pm on Jan 30, 2008 (gmt 0)



Hi there kiden.

I am sure our friend Dabrowski meant to say...


They should be parenthesis brackets rather than square brackets. ;)

birdbrain

Dabrowski

6:56 pm on Jan 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, I was using the technical term! ;)

Fotiman

7:23 pm on Jan 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I posted in haste. The case was only part of the issue. As was pointed out, you were using square brackets instead of parenthesis braces.


No, I was using the technical term! ;)

But the wrong technical term. :)
Curly brackets = {}
Round brackets = ()

[edited by: Fotiman at 7:24 pm (utc) on Jan. 30, 2008]

kiden

9:52 am on Jan 31, 2008 (gmt 0)

10+ Year Member



ah well, at least i was right on one thing yesterday and that's that i was being really silly...

thanks so much :) just couldn't see the wood for the trees.