You're using document.getElementByName
in the second file. You mean to be using document.getElementById
.
EDIT: you were, at least.
You're using document.getElementByName
in the second file. You mean to be using document.getElementById
.
EDIT: you were, at least.
It is because of the document.write function. After that you won't have a textbox in the document and so document.getElementById fails.
document.write statements must be run before the page finishes loading. This means that they must be either in the body of the page or in functions called from the body of the page.
Any document.write statement that runs after the page finishes loading will create a new page and overwrite all of the content of the current page.