If I understand what you're saying, you've got to let the page load first.
Simon Willison's addLoadEvent() is an option, as is the following if you're only executing one function on page load:
CODE
window.onload = function();
"window" could be replaced with "document" if it amuses you, as far as I know there is no difference.
Edit: Maybe this is what you're after. You've got to get ahold of the input, there are a number of ways of doing this. If it's got an id:
CODE
document.getElementById("...").firstChild.nodeValue;
document.getElementById("...").value;
You could also use getElementsByName:
CODE
document.getElementsByName("...")[0].firstChild.nodeValue;
document.getElementsByName("...")[0].value;