p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 1.0 and 1.1 Basics (http://p2p.wrox.com/forumdisplay.php?f=60)
-   -   on keypress (enter) jump to button (http://p2p.wrox.com/showthread.php?t=52388)

RoniR January 8th, 2007 04:42 AM

on keypress (enter) jump to button
 
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


dparsons January 8th, 2007 09:37 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


All times are GMT -4. The time now is 08:31 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.