I'm not sure if you still need this solved or not - this is an old post and came across it while looking for something completely unrelated, but in any event, I think I might have a solution you can try to implement:
<HTML><HEAD><TITLE>TEST</TITLE>
<SCRIPT language="JavaScript">
function loadBox(stuff) {
document.Form1.TextBox2.value = stuff;
}
</SCRIPT>
</HEAD><BODY>
<FORM name="Form1">
<INPUT type="textbox" id="TextBox1" value="Stuff here"/>
<INPUT type="textbox" id="TextBox2" />
<INPUT type="button" value="Click Me" onclick="loadBox(document.Form1.TextBox1.value)">
</FORM>
</BODY></HTML>
Not sure if it'll help, but it copies text from one textbox to the next with an 'onclick' event of a button. You pasted way too much code for me to go through to figure out if what you are trying to do is done on an interval or what (next time, just the applicable code you are trying to fix might be ok, or simplify it down to something like what I have above), as I'm not a PHP guy and hate the language, personally (it's just JavaScript on crack and I'd rather stick with the simpler, CLIENT-SIDE, and therefore FASTER code), but I would just tell you that you should probably just add the contents of the first textbox to the second at the same time as you do the first box. Just, within the same function that populates the first box, tell it to do a document.Form1.TextBox2.value = variable (and variable equals the same variable as the text that #1 got), rather than try to do some sort of poll of the box for when it gets populated. You could do that, though, if you really, really need to. Use "setInterval" and have it run a function every how-ever-often you need to - it would look something like this:
<SCRIPT language="JavaScript">
self.setInterval("doCheck()",5000);
function doCheck() {
if (document.Form1.TextBox1.value) {
document.Form1.TextBox2.value = document.Form1.TextBox1.value}
}
</SCRIPT>
That will check the box every 5 seconds for a value and send it to the 2nd box when populated. Only thing is, if you want it to stop at some point, you'll need a clearInterval in there, but you'll have to figure out what event you want to trigger that.
Cheers,
Tom