Maybe this is an easy question, maybe not. I have a select box where I hardcode with width. Say 120px.
<select style="width: 120px">
<option>REALLY LONG TEXT, REALLY LONG TEXT, REALLY LONG TEXT</option>
<option>ABC</option>
</select>
I want to be able to show the second option so that the user can see the full length of the text.
Like everything else. This works fine in Firefox, but doesn't work with Internet Explorer6.
A simple solution I used for an existing site in IE (using jQuery, but I can post back with
eventListener
code if you really don't know JS that well) is the following:Of course, use a variable (
var cWidth = jQuery('#mySelect').width();
) to store the previous width, but this is all that was required for ours to work as you'd expect.I improved the cychan's solution, to be like that:
The PNGs used in css classes are uploaded here...
And you still need JQuery.....
This mimics most of the behavior your looking for:
This will override some of the key-press behavior.
Place it in a div and give it an id
then create a really really simple css to go with it.
That's all you need.
If you have the option pre-existing in a fixed-with
<select>
, and you don't want to change the width programmatically, you could be out of luck unless you get a little creative.title
attribute to each option. This is non-standard HTML (if you care for this minor infraction here), but IE (and Firefox as well) will display the entire text in a mouse popup on mouse hover.If you are adding a long option later through JavaScript, look here: How to update HTML “select” box dynamically in IE
Sample
The below code will solve your problem of dropdownlist width by adding this code after insertion of Data to dropdownlist.