Subject: on keypress (enter) jump to button
Posted By: RoniR Post Date: 1/8/2007 3:42:39 AM
hi guys,ur help is needed yet another time.I have an asp.net webform in which the user can search.I want to apply something to directly jump to the search button when the user enters any criteria...ur help is appreciated

Reply By: dparsons Reply Date: 1/8/2007 8:37:30 AM
I use a similiar function, however, it prevents a user from pressing the enter button and having it submit a form.

function keyPress(e)
{
    var pressedKey = document.all? window.event.keyCode:e.which;
    return pressedKey != 13;
}
document.onkeypress = keyPressed;
if (document.layers) document.captureEvents(Event.KEYPRESS);

What this does is if the numerical representation of the pressed key is 13 (Key code for the enter button) it is disregarded and thus the enter button press do not do anything on the page this function is implemented on.  

To do what you want, you would alter the above function so that if the keycode is 13 you would call .focus on a form element.

hth.

-------------------------
I will only tell you how to do it, not do it for you.  
Unless, of course, you want to hire me to do work for you.

^^Thats my signature

Go to topic 52334

Return to index page 70
Return to index page 69
Return to index page 68
Return to index page 67
Return to index page 66
Return to index page 65
Return to index page 64
Return to index page 63
Return to index page 62
Return to index page 61