IE capture option element onclick Aug08 '06

Feedback

# (1 of 13): Tom

1 week, 3 days after the fact. (Fri 18 Aug 2006, 9:09 AM CST)

Doesnt work if you want to select the first item on the dropdown

# (2 of 13): Matthom

1 week, 3 days after the fact. (Fri 18 Aug 2006, 9:13 AM CST)

Good point. Just put an empty <option> element as the very first list item. That way, the REAL first option still has to be selected, therefore using the onchange event.

Previous comment Return to entry

# (3 of 13): Tai

1 month, 1 week after the fact. (Tue 19 Sep 2006, 3:26 PM CST)

This dog bit me for like an hour. Hate IE...

Previous comment Return to entry

# (4 of 13): Stoyan » svest.org

5 months, 2 weeks after the fact. (Fri 19 Jan 2007, 10:36 AM CST)

Two remarks:

  1. onchange="do( document.getElementById("do").value )" is invalid, bacause it has double quotes enclosed in double quotes. The right way is ="do( document.getElementById('do').value )"
  2. There is no need of getElementById at all, just use 'this': <select onchange="do( this.value )">

Previous comment Return to entry

# (5 of 13): Stoyan » svest.org

5 months, 2 weeks after the fact. (Fri 19 Jan 2007, 10:39 AM CST)

And validate your feedback against html entities :) So the second remark should be: 2. There is no need of getElementById at all, just use 'this':

Previous comment Return to entry

# (6 of 13): Matthom

5 months, 2 weeks after the fact. (Fri 19 Jan 2007, 10:49 AM CST)

Got it Stoyan, thanks. I made those changes.

Previous comment Return to entry

# (7 of 13): Mary

12 months after the fact. (Fri 03 Aug 2007, 2:04 PM CST)

it doesn't work. i can't make that example working

Previous comment Return to entry

# (8 of 13): Phpster

1 year after the fact. (Mon 27 Aug 2007, 7:02 PM CST)

Thank you very much for this information... And I hate IE!! I don't know how can Microsoft Create and support such a lousy browser!

Previous comment Return to entry

# (9 of 13): Klaus T

1 year, 1 month after the fact. (Tue 18 Sep 2007, 10:49 AM CST)

Any way to include some kind of "else" in this script? So that if none of the "case" are true, it will run a different function?

Previous comment Return to entry

# (10 of 13): Dbu

1 year, 9 months after the fact. (Wed 07 May 2008, 9:35 AM CST)

Klaus, there is the "default:" part of the switch/case statement.

... case "Do That" : // SPECIFIC CODE HERE break; default: // fallback code break; ....

default is used if none of the cases matched.

Previous comment Return to entry

# (11 of 13): Zebulon Evans » zebulonevans.blogspot.com

1 year, 9 months after the fact. (Tue 20 May 2008, 7:24 PM CST)

If you are looking for just the onclick and you are not using the drop down in a form this should work for you:

Previous comment Return to entry

# (12 of 13): Zebulon Evans » zebulonevans.blogspot.com

1 year, 9 months after the fact. (Tue 20 May 2008, 7:27 PM CST)

This time with the markdown syntax. If you are looking for just the onclick and you are not using the drop down in a form this should work for you:



Previous comment Return to entry

# (13 of 13): Iflow » iflow.anju-web.com

1 year, 11 months after the fact. (Sat 05 Jul 2008, 2:27 AM CST)

Thank you very much for the article! I hate IE ! :)

Previous comment Return to entry

RSS feed for comments on this post

Leave feedback

Feedback

Input format: The editor controls below will assist with Markdown syntax.

Status

Sub-status

Your info

Return to entry.

IE 6 does not support onclick event captures for <option> elements. Thankfully, there is still hope.

You are at the feedback permalink page for: IE capture option element onclick

Read more...