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

Auto submit from a Enter Key take two.....

Status
Not open for further replies.

FRANDAZZO

Programmer
Nov 29, 2000
60
US
I already posted this but I forgot 1 key issue I need this to work in netscape and ie...... That darn netscape...

Thanks

Frank

hi i had a really good idea for this but it is for a different language. i need this to work in javascript. anyway this was my idea and problem. when a user hits the enter button no matter what field he/she is in, the form has to submit. now i am already doing client side javascipt. so if the user fills out the last name input box and hits the "Enter" button on the Keyboard then the form must submit(actually call my jscript function). now in vb script i woulld just use to KeyAscii function and check to see is "13" the "Enter" key was pressed and then do something. is there any function like that in client side javascript.
 
this should work for both, you may have to tweak a little to get the right effect:

ns4 = (document.layers)?true:false;
ie4 = (document.all)?true:false;

function keyDown(e)
{
if(ns4){var keyhit=e.which;}
if(ie4){var keyhit=event.keyCode;}
if(keyhit==13)
{
document.formname.submit()
}
}

document.onkeydown = keyDown
if (ns4) document.captureEvents(Event.KEYDOWN)

//modified from dansteinman.com jared@aauser.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top