Update to "Select Boxes with Style"

by Castwide on 4-9-2008 • Tags: css, ie, javascript, select, style0 comments

A visitor commented under the article "Select Boxes with Style" that the solution did not work in Internet Explorer 6. Today I revised the JavaScript code so it works the same in IE 6, IE 7, and Firefox 2.

The problem was with the onclick event that called the function to highlight the appropriate selections.  The function was called from the input (radio or checkbox) onclick events.  IE 6 ignored the event, apparently because the inputs were not visible.

The solution was to add some extra code for IE so a click event on a label would call the appropriate input's click() function, thereby triggering the function to highlight the selected options.

Due to the above, it was also possible to remove a different block of IE-only code that used an alternative method of hiding the inputs.  Now all browsers can simply use display: none.

The updated code is available in the original article.  Thanks to the reader who mentioned the problem.

There are no comments posted to this news item.

Add Comment

More Articles