• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Dealing with Users Pressing Enter in ASP

 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps this is a bit off topic, but it seems to be the best place to put this and I was hoping, if no one else knew, Eric would have some experience with this.

In the past, I've run into problems with browser differences and how they handle various keystrokes. I've also solved this a number of different ways.

My current problem is that I've built an ASP application for a bunch of folks that are used to mainframe applications and Windows Emulators. In those environments, the Enter key is mapped such that it advances focus from one field to the next. In Internet Explorer (v6), however, pressing the Enter button seems to grab the first button and the form and presses it for you. In my case, this is causing a form submission when the user really just wants to go from one field to the next in the form.

While this is useful in some ways, some of the users have complained about it. I'm not entirely certain that I want to "fix" this behavior or not, but I thought I'd ask the question.

Has anyone found a good way to deal with users pressing the Enter key instead of Tab?

Thanks,
Corey
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I actually have this in chapter 16 of my book. I will post the code tomorrow morning. I am pulling an all nighter to meet a deadline for my book.

Yikes

Eric
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, I forgot about you!

I will find the code and post it in a few.

Eric
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here you go...


There are some other ways to do i that are more dynamic, but this is the easiest way of doing it.

Eric
[ July 14, 2004: Message edited by: Eric Pascarello ]
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Eric. This looks like a viable solution. However, there is one line in here that confuses me. What does this do?

 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is browser specific code to adjust for DOM differences on how it handles objects.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Eric Pascarello:
It is browser specific code to adjust for DOM differences on how it handles objects.



Ok, two questions for you, then.

1. The customers that will be using this application will be using Internet Explorer only. Do I need that line?

2. If the variable "event" is available from the JavaScript method, what's the point of passing it as a parameter?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

1. The customers that will be using this application will be using Internet Explorer only. Do I need that line?


You can use the code with the else statement if I remember correctly....Brain Fried...I personally would leave it alone, unless you are counting bytes.

2. If the variable "event" is available from the JavaScript method, what's the point of passing it as a parameter?

Certain older browsers needed the event reference to be passed.



I feel like I am being interviewed.....
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I feel like I am being interviewed.....



Hehe. Just trying to get a feel for what's going on. If I'm going to use this, I want to know what it does.


Certain older browsers needed the event reference to be passed.



If that's the case, wouldn't you want to always refer to the variable that was passed, rather than some of both? In your code, you have these two lines:

if (window.Event) keyCode = evt.which;
else keyCode = event.keyCode;

The first refers to the passed variable while the second refers to the variable as if it were global. I imagine it would be safer to do this:

if (window.Event) keyCode = evt.which;
else keyCode = evt.keyCode;

Is that correct?

Thanks for all the help, Eric.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
was the second step of statments supposed to be the same there?
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Eric Pascarello:
was the second step of statments supposed to be the same there?



No, they're different. In the second set of statements, I refer to the passed variable evt, not the "global" variable, event.
 
This tiny ad is wafer thin:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic