Forum Moderators: open

Message Too Old, No Replies

How to tell how form was submitted?

Was it a click of the submit or a whap of the enter key?

         

RossWal

12:33 am on Dec 11, 2002 (gmt 0)

10+ Year Member



I need to have the enter key serve as a tab key under some conditions, and have it default as the submit button under others. Yeah, I know this detracts from useability, but this is for a specialized, limited, and controlled group of users, and that's what they want.

I was dismayed to find that when the whap of the enter key defaults to the submit button, both the onFocus and onClick events fire for the submit button.

Now I'm playing with hiding the submit button and using a 'button button' to trigger the submit manually. Thus, if the Submit button's events fire, I know we had a whap of the enter key vs a mouse click for the button button.

Three questions:
Am I making any sense here?
Am I making more of this than I need to?
How to hide the submit button? Style="height:0px" did not do the trick.

Thanks much for ideas!

tedster

5:11 am on Dec 11, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Am I making any sense here? Am I making more of this than I need to?

Only you can judge how important this is for your site/application. I personally don't take it well when clients insist on things being overly complex or non-standard...I talk them into the K-I-S-S principle.

How to hide the submit button? Style="height:0px" did not do the trick.

Have you tried style="visibility:hidden;" or style="display:none;"?

The first will keep the same document formatting, preserving the space the element takes up and the second completely removes the element from the document flow.

msr986

5:34 am on Dec 11, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could try using an image for the submit button:

<input type="image" src="image.gif" border="0" name="submit">

Then you could test the values submit.x and submit.y to see if they are greater than zero. If the submit is triggered by the enter key, submit.x and submit.y will be equal to zero. (unless the pointer happens to be on the button).

But, I'm not sure if you can successfully test the x and y coordinates in JavaScript.

RossWal

6:28 pm on Dec 11, 2002 (gmt 0)

10+ Year Member



Thanks for the comments. Tedster, I appreciate the bias towards keeping it simple, but this is really a specialized case of optimizing for rapid data entry in a remote part of Alaska with bad line speeds.

Don't know why I missed this the first time around, but I'm now using the mouseover/mouseout events to tell whether it's a real click on the submit.

txbakers

7:44 pm on Dec 11, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What's wrong with using the TAB key as a TAB key?

I'm baffled by your need to use the ENTER key as a TAB.