A: 

You're using document.getElementByName in the second file. You mean to be using document.getElementById.

EDIT: you were, at least.

Peter
oh i was checking though in my code, pasted here too :) sory
ammar
A: 

Try alert(document.getElementByName("commandtextarea").value alone.

samer
i tried this, but not working :(
ammar
+6  A: 

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.

rahul
+1, document.write misunderstandings cause a lot of confusion. Squirt your html into an element using document.getElementById("myElement").innerHTML = "<p>My HTML</p>";
Sohnee
A: 

Get the firebug plugin for firefox so you can debug it. It's really straight forward, saved me hours of time just today :-)

jskaggz
the file is a big one, firefox debugger is taking so much time
ammar