Click to See Complete Forum and Search --> : onClick in a Select tag


linnium
05-15-2003, 03:16 PM
A request was put in for a user to be able to hit the enter key when an option on a drop down menu is highlighted. The onClick="submit()" didn't seem to work. Any ideas?

Jona
05-15-2003, 03:18 PM
Not sure what you mean.

<select size="3" name="slct">
<option value="-1">Pick one:</option>
<option value="1" onClick="this.form.submit();">A</option>
<option value="2" onClick="this.form.submit();">B</option>
<option value="3" onClick="this.form.submit();">C</option>
</select>

linnium
05-15-2003, 03:27 PM
Yes, that is what I was going for, but I tried that just a moment ago, and it didn't seem to like that either.

Jona
05-15-2003, 03:33 PM
Use onchange="this.form.submit();"

linnium
05-15-2003, 03:38 PM
Yeah, they don't want to have it automatically submit on change, because the way the imagine the user behaving is typing in a login, hit tab to get to the next field, etc., but once they tab to the drop down and use the arrow keys to select a value in te drop down, that they will then hit the enter button. It's basically to remove one extra step from the process instead of hitting tab once again to get to the submit button.

If it can't be done, it can't be done. But I thought I'd explore my options before saying no. Thanks.

Jona
05-15-2003, 03:41 PM
Oh, you want an onKeyPress="if(window.Event){if(event.which==13) this.form.submit();}else{if(event.keyCode==13) this.form.submit(); }"

linnium
05-15-2003, 03:58 PM
I'm not able to get that to work either. Don't sweat it. It is more trouble than it's worthy. Let the bums hit tab another time. TGhanks for your help though.

Jona
05-15-2003, 04:02 PM
Were you using Netscape? If so, change event.which to evt.which