View Full Version : document.getElementByID is not a function ??

09-05-2006, 05:32 PM
I'm really tearing my hair out, please help.

I have...

<div id ="chatPanel"></div>

I have a function in the <HEAD>:

function chatMessage(sender, message)
document.getElementByID("chatPanel").innerHTML+= "<b>" + sender + "</b> - " + message + "<br>";

When I call chatMessage("me","some stuff"), the javascript console informs me that document.getElementByID is not a function!


<button onClick="document.getElementById('chatPanel').innerHTML+='BOOM!'">BOOM!</button>

appends to the div just fine when you click the button.

So confused, please help.

09-05-2006, 05:48 PM
function chatMessage(sender, message)
document.getElementById("chatPanel").innerHTML+= "<b>" + sender + "</b> - " + message + "<br>";

note Id not ID

09-05-2006, 10:42 PM
use rather DOM methods instead of innerHTML.

Anyway getElementById() is not a function, is a method.

Javascript is case sensitive. see the red character.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum