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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the Enter key

Status
Not open for further replies.

pbprog

Programmer
Nov 1, 2000
1
CA
Can I use the enter key to submit information from a form? There are two fields, login and password, and when the user hits Enter I want to go do programming stuff. I've looked everywhere, but am coming up blank. Help!
 
pbprog,

here the code i use for my login page, where "13" is the ASC number for enter key

<script language=&quot;JavaScript&quot;>
IE4 = (document.all);
NS4 = (document.layers);

if (NS4) document.captureEvents(Event.KEYPRESS);
document.onkeypress = ShortCut;

function ShortCut(e) {
whichASC = (NS4) ? e.which : event.keyCode;
switch (whichASC) {
case 13:
document.login.submit();
return false;break;
default:break;
}
}

hope this helps

Chiu Chan
cchan@gefmus.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top