View Full Version : Select Option Onclick Question

05-03-2008, 08:57 PM
I want to make an option in a select menu blink a few times when you select it. My first issue, is doing any action on click/focus of a select option, (the option tag)

I tried using onclick, but this does not work in IE. (Does work in Firefox.) Then i tried onfocus, and this does not work in either. So my first question is this, how do I get an action to run when the option is selected? (By the way, onchange does not run until the select loses focus.)

My second question, though it does not need to be answered here, is how can I make the option blink? Either changing the background color a few times, or focus and defocusing the option both work, I just need it to two or three times.

Thank you.

05-04-2008, 01:53 PM
I think the only real option is to make your own "select element" out of divs because I do not think that IE supports onclick or any other option on the select tag or on the option tags.


05-04-2008, 08:24 PM
The select element does support onchange at the very least, and I beleive onclick, onfocus, and onblur. I was able to use onchange to run a function that used setTimeout to change the background color back and forth, there by creating the effect I was after. (Note: You should take away the focus of the select before doing this so that you can see it in IE, otherwise the selected option will stay highlighted.)

I also mentioned that onchange does not trigger until the element loses focus; I had fogotten that this only applys to inputs, textareas, and maybe checkboxes. Selects trigger onchange as soon as a new option is selected, (at least in single mode.)

Thanks for your help though.

Arty Effem
05-05-2008, 12:34 AM
I want to make an option in a select menu blink a few times when you select itHow ever did we manage without that? (http://scripterlative.com/test/blinkoption/)