How to expand 'select' option width after the user wants to select an option

Berlin Brown picture Berlin Brown · Nov 16, 2008 · Viewed 142.8k times · Source

Maybe this is an easy question, maybe not. I have a select box where I hardcode with width. Say 120px.

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.

Answer

cychan picture cychan · Feb 19, 2009

I fixed my problem with the following code:

<div style="width: 180px; overflow: hidden;">
   <select style="width: auto;" name="abc" id="10">
     <option value="-1">AAAAAAAAAAA</option>
     <option value="123">123</option>
   </select>
</div>

Hope it helps!