/    Sign up×
Community /Pin to ProfileBookmark

onClick in a Select tag

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?

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@JonaMay 15.2003 — 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>
Copy linkTweet thisAlerts:
@linniumauthorMay 15.2003 — 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.
Copy linkTweet thisAlerts:
@JonaMay 15.2003 — Use onchange="this.form.submit();"
Copy linkTweet thisAlerts:
@linniumauthorMay 15.2003 — 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.
Copy linkTweet thisAlerts:
@JonaMay 15.2003 — Oh, you want an onKeyPress="if(window.Event){if(event.which==13) this.form.submit();}else{if(event.keyCode==13) this.form.submit(); }"
Copy linkTweet thisAlerts:
@linniumauthorMay 15.2003 — 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.
Copy linkTweet thisAlerts:
@JonaMay 15.2003 — Were you using Netscape? If so, change event.which to evt.which
×

Success!

Help @linnium spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...