Hi all,

I have a problem with SetTimeOut() function,

I have Personal messageing system on my site and I tried to configure it, and decided to make it in this sorting:

1. when user recive message from another user, it shows two buttons "Open" and "Close", whan user clicks on "Open" button, new window popups and there are simmple form objects one textarea and two buttons, "Send" and "Close"

2. When user clics on "Send" button in the popup window, the form have to send the data from textarea and close the popup window, ok here I have problem, when I click "Send" after entering some text in the textarea field, it seams that everything is ok and it sends the text and closes the window, but one time it works one not, because it's closeing the window so fast and one time it's submits the data from textarea , one time not... so I decided to put SetTimeOut() Function with OnClick in the code of button "Send" but it not worked for me, I also tried to do it with OnSubmit in the form code, it wasn't work too... so I don't know how to solve this problem please help somebody who is well in javascript...

p.s. Is there any way with javascript to check for example: when user click button "Send" the script start to check if it's ok and message was sent then close the window, if not return error?

Thanx all, and sorry for bad english

here is the code from PHP file:

Code:
$pm_alert = <<<HTML
<table style="border: solid 1px #999; position:absolute; top:510px; left:18px; width: 237px;" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="218" align="center" valign="top"><div id="message"></div>
	<div style="title="{$lang['pm_mtitle']}" >{$lang['pm_atitle']}</div></div>
    <div style="height: 225px; width: 218px;"><br />{$lang['pm_alert']}
    <br /><br /><img src="/uploads/fotos/{$row['foto_name']}{$member_id['foto']}" width="100" style="margin-right:10px;"  /><br />{$lang['pm_asub']} <b>{$row['subj']}</b><br />{$lang['pm_from']} <b>{$row['user_from']}</b></b></div><br />
    <div align="center" style="width: 220px;">
    <textarea style=" font-size:14px; font-family:Verdana, Helvica, Sans-serif; font-style:normal; border:0px;" name="txtMessage" cols="27" rows="18" readonly="readonly"  id="message">{$row['text']}</textarea>
	</div><br />
    
		<div style="width:198px;"><FORM><INPUT TYPE="BUTTON" VALUE="{$lang['pm_aread']}" onclick="createPopup();"> <INPUT TYPE="BUTTON" VALUE="{$lang['pm_close']}" ONCLICK="window.location.href='javascript:location.reload();'"></FORM> </a></div><br /><br />
        <div>
       </div>
</div></td>
  </tr>
</table>
<script language="Javascript" type="text/javascript">
function createPopup() {
//Get the data from the form fields

//Now create the HTML code that is required to make the popup
var content = "<html><head></head><body><form action='' method='post' name='answerForm'><table width='450' border='0' cellpadding='0' cellspacing='5'><tr><td><img src='/uploads/fotos/{$row['foto_name']}{$member_id['foto']}' alt='' name='imgPlaceholder' width='110' height='110' id='imgPlaceholder' /></td></tr><tr><td><label><strong>Nickname: </strong>{$row['user_from']}</label></td></tr><tr><td><label><strong>Subject:</strong> {$row['subj']}</label></td></tr><tr><td><textarea name='comments' id='comments' value='' cols='50' rows='10'></textarea></td></tr><tr><td align='right'style='padding-right:20px;'><input type='submit' name='btnSend' id='btnSend' value='Send' onclick='opener.focus();opener.location.href = opener.location;self.close();' />&nbsp;<input type='button' name='btnCancel' id='btnCancel' value='Cancel' onclick='window.close(this)'; /><input name='send' type='hidden' value='send' /></td></tr></table><input name='subj' type='hidden' value={$row['subj']} /><input name='name' type='hidden' value={$row['user_from']} /></form><br /></body></html>"
	
var pops = window.open("","window","resizeable,left=400,top=400,width=458,height=500"); //Create the popup
pops.document.write(content); //Write content into it.
pops.document.close();	
pops.document.getElementById('comments').focus();
}


</script>


HTML;
Screenshot:
screen003.jpg