Submitting a Form Using Enter in Netscape
By Brian RheeThis article is a follow-up from Brian's earlier article, Incompatibilities in IE and Netscape: HTML & Javascript
Since I posted that little article the other day about the inconsistencies between IE and Netscape, I have received many e-mails of high praise and thanx (yes I spell it this way)... So thank you for your kind words of appreciation.
However, I did not expect to be asked by so many people regarding the script with the submit button/image in Netscape.
So here is some sample code to help you along your way. This script is very simple and shouldn't be a problem for anyone to implement.
|
BTW: I have received a couple of e-mails by people who have written code
similar to this but instead of submitting the information they
fire a text box first to notify the user of errored or blank fields.
Under Netscape, if you were to simply use the code I have written the
message box pops up but it repetedly pops if you try to close the alert
box using the "enter" key, in IE this is not a problem.
So the way to solve this problem is to specify where, or rather which,
element in your form you want this "return" submit to work with. The
code above shows you how to do this by setting some additonal conditional
statements using the evt.target.type and evt.target.name.
BTW2: This code is highly configurable and as you can see I have isolated the event that occurs when one hits the "enter" key. Instead of submitting a form you can focus on an image, or send the user to another url, or do some inline processing in the page to calculate totals or something...Hope these ideas seed your brain with the endless possibilities...
One last thing: I have also written a kewl (yes I spell it like that) little index search script using ASP and JavaScript...Like the one you can find in the index help search menu of any Microsoft program. I found it very handy for searching through large list boxes. The code is fairly long but very simple, however it would take me some time to write an article about it. So if enough people are interested please post to the 4GuysFromRolla message board under WANNA SEE MY INDEX SEARCH SCRIPT.
Happy Programming!




