Gossamer Forum
Home : General : Perl Programming :

<enter> form submission

Quote Reply
<enter> form submission
Ok, I have a page using frames like:

Code:
____________________
| | |
| | |
| | |
| | |
|____________ | |
| | |
|_____________|_____|

Well you get the drift :)

In the bottom frame I have a form, well I say form, it is like this:

<form name="post">
<input type="text" name="message" class="text" size="80">
<input type="button" value="Post" class="button" onclick="post_me(post.message.value);">
</form>

....now, currently if you try to submit the form by hitting return, it reloads the main frame in the bottom frame.

Does anyone know how I can get "return" to submit the form (well basically it just needs to call the post_me() function.

Do I need an "onLoad" event in the body tag or something like that to detect the keypress?

I've tried using:

if (window.event.keyCode == 13) {

...but can't get it to work :(

Last edited by:

RedRum: Mar 3, 2002, 3:21 PM
Quote Reply
Re: [RedRum] <enter> form submission In reply to
Im so proud of myself :) .....I got it to work...woohoo

<body onkeypress="return check_key();">

Code:
function check_key() {
if (window.event.keyCode == 13) {
post_me(post.message.value);
return false;
}
}

Last edited by:

RedRum: Mar 3, 2002, 3:33 PM