In your case looks like:
the code that fills the text box via javascript needs to be attached with onload event of page at script side
like:
try this in your javascript
<br />
<br />
function fillTextBox(){<br />
}<br />
<br />
window.attachEvent('onload', fillTextBox);<br />
<br />