Jump to content

[SOLVED] Select WIDTH in IE


EagerWolf

Recommended Posts

<form id="form1" name="form1" method="post" action="">
  <label>
  <select name="select" style="width:150px">
    <option value="1">sdasdadasasdsasaddsaasdsa</option>
    <option value="2">sadasdasfasfasasfasfasf</option>
    <option value="3">asd</option>
  </select>
  </label>
</form>

If you put this in html file and open it with IE.. You will see, that values (sdasdadasasdsasaddsaasdsa) aren't shown correctly.. box with 150px width is opened when select is clicked... In other site Firefox shows it correctly...

 

Link to comment
Share on other sites

IE won't show the entier text in the select menu width is smaller than the option, you need to use a script to resize the width to "auto" when the menu is open using onclick events. It's a bit complicated since you'll need to track if the user clicked on the menu to open it or to close it.

 

Something like this

 

When the user click on the menu, a click counter will recorde the click to 1 which means the menu is open.

 

If the counter is 1 set the width to auto

 

the user make a selection, set the counter to 0

 

if the counter is 0 set the width to 150

 

Things you need to worry about is if the user click outside the menu to close (you'll need an onclick event on the body)

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.