View Full Version : Best way to grab enter key.
aluminumpork
03-04-2006, 01:48 PM
I've got a standard textarea that is used to type a message. I need a way to grab the enter key for the sendMessage() function.
What's the best way to do this?
Thanks
coothead
03-04-2006, 03:35 PM
Hi there aluminumpork,
does this example help...
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>grab enter key</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
function sendInfo(e,df) {
if((document.all)&&(e.keyCode==13)) {
df[0].submit();
}
else {
if(e.which==13) {
df[0].submit();
}
}
}
//-->
</script>
</head>
<body onkeyup="sendInfo(event,document.forms)">
<form action="http://www.google.com" method="get">
<div>
<textarea name="txtra" rows="3" cols="20" ></textarea>
</div>
</form>
</body>
</html>
aluminumpork
03-04-2006, 05:07 PM
Perfect! Thanks!
coothead
03-04-2006, 05:11 PM
No problem, you're welcome. :loopy:
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.