Originally posted by Vladdy
Someone on another forum was complaining about the inability of listbox to scroll horizontally and view long items, so I whipped up a little demo that replaces select elements (with size set to 2+) with a div element and hidden input element thus emulating the listbox control.
The code is IE only, but can easily be modified for Gecko compliance by rewriting event related routines.
The beauty of the approach is that in antique (NS4.*) and wannabe (Opera) browsers and others with JS disabled the select element is still there, so usability is not impacted at all.
In a div element that replaces the listbox all styles are customizable. Tooltips are implemented for items that exceed the box width.
The code can also be extended to include OPTGROUP recognition thus making the emulation complete.
It will also solve the problem with the IE bug that renders listboxes (and other controls) above everything, regardless of z-index setting.
The code was tested only in IE6.0 (I said, it's something I wipped up over the lunch hour) but should work with IE 5+.