Clear on Enter Key pressed not working.

Siaram

New Member
Messages
81
Reaction score
1
Points
0
Hi,

I have a from on my web site that post into an iframe. To save bandwith, only the iframe autorefresh and the rest of the page remain the same. In my form, I have 1 textbox for comments to be left and 2 buttons, 1 to submit and the other one to reset the comments field. I want to get rif of the reset button and get it done automatically when posting the form. Here is the scripts I'm using to autoclear the box.

<script language="JavaScript" type="text/javascript">
function realSubmit() {
document
.myform.submit();
document
.myform.comment.value = '';
}
</script>
<script language="JavaScript">
function checkEnter(event)
{
code
= event.keyCode;if(code ==13){
document
.myform.submit();
document
.myform.comment.value = '';
}
}


And here is my form.

<form name="myform" method="post" action="ChatBox.php?sec=post&cat=<? echo $cat; ?>" target="shout">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr valign="top">
<td width="15%" class="txtdcel">Username : </td>
<td width="35%" class="txtdcel">
<input name="name" type="hidden" class="textbox" id="name2" size="20" maxlength="30" value="<?
echo $user; ?>"/>
<?
echo '<b>'.$user.'</b>'; ?>
</td>
<td class="txtdcel">
<div align="right">
<em>iBuzzz Chat</a>
</em>
</div>
</td>
</tr>
<tr valign="top">
<td class="txtdcel">Message : </td>
<td colspan="2" class="txtdcel">
<input name="comment" type="text" class="textbox" id="textarea" size="58" rows="3" style="border: groove; font-family: Verdana; font-size: 12px"
onkeypress="checkEnter();"
>

</td>
</tr>

<tr valign="middle">
<td colspan="3" class="txtdcel">
<div align="center">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a
href="#cbox" onClick="Javascript:refreshCB()">Manual Refresh</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="fakesubmit" type="button" value="Post!!" onclick="realSubmit();" style="border: ridge; font-family: Verdana; font-size: 12px">
<input name="Reset" type="reset" class="textbox" value="Reset" style="border: ridge; font-family: Verdana; font-size: 12px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a
href="#cbox" onClick="Javascript:refreshLoop()">Enable Auto Refresh</a>
</div>
</td>
</tr>
</table>
</td>
</form>


Now, the code is working ifne in ff, IE7 but for some reasons, it doesn't work in IE6... when pressing the fake submit button, it submits the comment and reset the comment box, but if you do an enter key in IE6, it resets the comment box and forgets to post.

Thanks for any help :)
 
Top