I thought this was going to be a simple problem but it stumped me. Basically what I want to do is alert the id value of the option that is currently being displayed from a select menu. So if I select English, I want "en" to be alerted and if I select Spanish I want "es" alerted. So far with what I have, only "es" gets alerted regardless of which option I select. I guess it is because, the first child of the select menu is automatically chosen according to the code. So how do I make this work the way I want?
I also tried
Didn't get to try it, but how does that work if you change the values via keyboard? I remember one time had a pain between onchange and onclick (via regular javascript) as for those used to using TAB between fields and the doing up/down arrow to change, it gave me headaches getting it to work well.
twinedev wrote:but how does that work if you change the values via keyboard?
good point; i'm not sure if the question is for me but here goes: even with the 'click' action is changed to 'change' using the keyboard doesn't show the alerts, this is refering to my script. The OP's script i couldn't get working either with change() in place.
http://api.jquery.com/change/
The first example i can't get to work but the second one works using change(); might be useful to OP.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering