Ahmed Masud
Ahmed Masud

Reputation: 612

getelementbyid not working

HI I am trying to get div from getelementbyid but it isnt working for me this is my code

 <body onload="ErrorCheck(-1)">
<script type="text/javascript">
function ErrorCheck(var1)
{

    if(var1 = -1)
    {   alert("in function");
        var cont = document.getElementBId('msg');       
        if(cont==null){
        alert("null");
        }
        else{
        alert("not null");
        }
    }
}
</script>
<h1 class="header">Register</h1>
<div id="msg"></div>
</body>

after getElementBId is called this function becomes dead as it doesnt go to any if or else. Please check what am i doing wrong here

Upvotes: 0

Views: 555

Answers (2)

ppsreejith
ppsreejith

Reputation: 3438

Errors Include the following

line 6 is

if(var == -1)

And the next is

document.getElementById // not document.getElementBId

Upvotes: 2

mgraph
mgraph

Reputation: 15338

you forgot y before ...Id('msg'); :

var cont = document.getElementById('msg'); 

Upvotes: 5

Related Questions