views:

251

answers:

5

While using fixed width select tag , there is one bug in IE. When the content of the option in the select tag is more than the width of select tag its hide. Its working fine in fire fox , not in IE.

alt text

+2  A: 

This is a bug in IE, and there is no way to solve it, apart from making the select box wider:

<select style="width: 500px;">
  <option value="1">
    This is a very long option, but it's cool, cause the select is also very long
  </option>
</select>

Another alternative is to use a framework that will replace the selectbox with a styled combination of other elements. They will behave like a selectbox, but require javascript to work.

Marius
It is not a bug, it is a feature.
epascarello
lol classic .... +1
almog.ori
A: 

I've never tried this, but you could try setting the input field

position: absolute

and e.g.

width: 500

onFocus, and set it back to normal onBlur. You may have to modify your layout slightly so it doesn't jiggle but I can't think of anything why this should not work.

Pekka
+2  A: 

The solution I came up with (which I didn't find anywhere in all of my googling) was very simple: when a user clicks the select list, swap out the class to one without width restrictions. When they make a selection, swap the class back to one WITH width restrictions.

heres a sample using jquery.

$(function() {

$(".SecuritySelect")

    .mouseover(function(){
        $(this)
            .data("origWidth", $(this).css("width"))
            .css("width", "auto");
    })

    .mouseout(function(){
        $(this).css("width", $(this).data("origWidth"));
    });

});
almog.ori
You should propably do something with fixed positioning and such, because this will reflow the page.
Pim Jager
Agreed, this IS a bit of a hack
almog.ori
A: 

Hedgerwow has an excellent solution to this issue:

http://www.hedgerwow.com/360/dhtml/ui%5Fselect%5Fwith%5Ffixed%5Fwidth/bk/demo.php

It drops in a really slick DHTML menu, but does it very cleanly. Solid fix.

Paul Irish
+1  A: 

Listed solutions are poor. One I found and used was

$('select#CourtId')
    .focus(function() { $('select#CourtId').css('position', 'relative').css('margin-right', '-300px').css('min-width', $('select#CourtId').css('width')).css('width', 'auto'); })
    .blur(function() { $('select#CourtId').removeAttr('style'); });
Veton