OVERVIEW OF PROBLEM
A form handler is not working when a user submits a form using the Enter key, instead of clicking on a button in the form.
It works when the form has more than one textbox. If the form has one or zero textboxes, it doesn't work.
Link to page that demonstrates the problem:
Everything works fine when a user clicks on one of the buttons in the form. The buttons are coded as
<input type="image" src="xxx.jpg" name="buttonName1">
<input type="image" src="xxy.jpg" name="buttonName2">
Each button as a different name. Here is a link to a page that shows this:
The form handler figures out which button was clicked button by looking for a non-empty value in
"). (The .x refers to an x-coordinate value that gets put into the form collection for the image that was clicked...personally, I think this is a lame way to do things, but whatever....). To view ASP source code:
If a user hits the ENTER key, instead of selecting a button, the first button in the form gets a non-empty value posted to its x-coordinate in the form collection.
For some (dumb) reason, this doesn't work when there are less than 2 textboxes in the form. In the case where there are one or zero textboxes in the form, nothing gets posted to the x-coordinate of the first button. Maybe there is a good reason for this, but it seems like a bug in HTML to me. But such is life. Here is a link to a demo of this scenario:
This "feature" causes a problem for our form handler. Specifically, our form handler interpets the case where no buttons where selected as something you don't want to know about, but I cannot change (another programmer set this up, and he is the CEO's brother in law).
What should I do about this? I need a way to tell the form handler that to use the first button on the form if the user hits the ENTER key.
I realize this is a nebulous question....I'll award points to all contributors as fairly as I can. Humor awarded as liberally as technical contributions.