having problems with javascript null

Posted by user165242 on Stack Overflow See other posts from Stack Overflow or by user165242
Published on 2010-04-22T08:42:28Z Indexed on 2010/04/22 8:53 UTC
Read the original article Hit count: 199

Filed under:

I have tried rectifying the code below. But I am not able to find a solution. After executing the code, firebug says "document.getElementById(haystack.value) is null". I tried if(document.getElementById(haystack).value ==null) but it was of no use. Please help me out.

     var haystack=document.getElementById('city1').value;
 if(!document.getElementById(haystack).value)
 {
   alert("null");
 }
 else
 {
   alert("not null");
 }

© Stack Overflow or respective owner

Related posts about JavaScript