I am having a brain fart.. I can not remember how to set a button as the default to the enter key. I thought it was setting the tab index to 0 and the other buttons to (1,2,3,4, ect).
I've gone around and around with that problem. Sometimes it works as described in various places on MS's website, sometimes it's just bunk.
Instead I made a JavaScript workaround and it ended up opening a whole new avenue of possibility.
Here's the code.
Code:
<!-- In the <Head> tag -->
<script lang="Javascript">
function onkey() {
if (window.event.keyCode==13) {
document.all["buttonname"].focus();
}
// You could even put in a "Home" key function!
if (window.event.keyCode==36) {
window.location="homepageurl";
}
}
</script>
Then the <body> tag looks like this...
Code:
<body onkeydown="onkey();">
Of course there's a million things you can do... use a "switch" block to make a whole keypad interface... etc.
If you have multiple possible default buttons (based on what control may have the focus at the time), then you'll want to add a <input id="a" type="hidden"> tag and then use the onfocus events of the text boxes to change the value of the hidden field. Then put an "if" inside the "keycode is 13" block to see which button to send the focus to before the enter key is processed.
Sorry for the long answer but I've gone around and around with this problem myself, and a lot of trial and error has come to this conclusion...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.