Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit form by pressing the enter key

Status
Not open for further replies.

arneweise77

Programmer
Apr 25, 2002
46
SE
Hi, a simple question on how to submit a form with keydown event. I´ve tried a function with KeyPressOnEventArgs as one argument which it didn´t recognize. Do someone have a function that could help me with this problem?

thanx in andvance
Arne
 
I may be mistaken but you are trying to capture a event in the client - i think the only way you can do this is using javascript:

document.onkeypress=kpress;

function kpress(e){
key=(document.layers)?e.which:window.event.keyCode
if (key == 13){
alert('ENTER PRESSED');
}
}
 
The enter key "clicks" the first button in your code. That is the button that appears first in the code (not necessarily the first you see on the page).

See this post for more information on having multiple buttons able to accept the enter key as a submit.
faq855-3257 The post you want is 2nd from the bottom.
It links to this page

That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top