You are likely running that script before the
element is reached in your code, so it doesn't exist when you try to access it. Make sure that your script comes after your input (or you wrap your script in a document onload event handler so that it doesn't execute until the page has fully loaded)