Category: Javascript

document.getElementById return NULL when the control only have name attribute

A webpage was working well on the development machine but when I moved it to the server the document.getElementById returned null. Here an example: <script> alert(document.getElementById(“test”)); </script> <body> <input name=”test” type=”text” value=”testing..”> </body> The above alert should show the message “[object]” but it returns null. After few hours of troubleshooting it turned out that the