Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts

    Select Option Onclick Question

    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.
    If I'm postin here, I NEED YOUR HELP!!

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts
    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.
    If I'm postin here, I NEED YOUR HELP!!

  • #4
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by Ultragames View Post
    I want to make an option in a select menu blink a few times when you select it
    How ever did we manage without that?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •