I have got a text area input control.
I want to know the name of the event when an user hits enter inside the textarea.
Anybody can tell me how to submit a form and clear the contents in the text area when the user hits 'enter' inside the textarea.
Is it possible to format the <input type='submit'> button; add some style to it? I dont want images that change on mouseover and mouseout rather pure html submit buttons like the ones like preview and submit buttons in this forum?
<html>
<head>
<script language = 'javascript'>
function processTextArea(value){
frmChatMessage.submit();//submit the form
frmChatMessage.taMessage.value = "";//reset the text area field
}
</script>
</head>
<body>
<table>
<form name = 'frmChatMessage' method = 'get' action = ''>
<tr><td><textarea id = 'taMessage' name = 'taMessage' rows = '2' cols = '45' onkeypress= 'javascript:"processTextArea(this.value);"'><chat message></textarea></td>
<td><input type = 'submit' id = 'subMessage' name = 'subMessage' value = 'Send' ></td></tr>
</form>
</table>
</body>
</html>
Actually, I dont want to use the value in the text area.
I simply passed that value to the function,,pls ignore it.
I will give you the whole situation so you can help me better.
I have a textarea for the chat user to type in. I dont expect him to click on the send button rather if he hits 'enter' on the keyboard the form should submit and the content in the text area should be cleared.
you may want to look up some tutorials on how onkeypress works. The event is already in Javascript, so telling Javascript it's going to run Javascript is kinda... silly. You'll also find out that any keys being pressed inside the textarea will fire the event. You must filter it down to the characters you want to look for (there are multiple keycodes for "enter" depending on encodings, among other things..)