this is my code :
<body>
     <p id="x"></p>
     <p id="y"></p>
    <form action="2.php" method="post" name="frm">
        <input type="text" name="srch">
    </form>
    <script>
        obj = document.forms["frm"]["srch7"];
        obj1 = document.getElementById("noexist");
        document.getElementById("x").innerHTML = obj;
        document.getElementById("y").innerHTML = obj1;
    </script>
</body>
why obj return undefined but obj1 return null, document.forms["frm"]["srch7"]; and document.getElementById("noexist"); both are object and must return null,because elements no exist.
 
     
     
     
     
    