Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 410495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:53:39+00:00 2026-05-12T17:53:39+00:00

So I’ve got some <select> tags that I would like to show the entire

  • 0

So I’ve got some <select> tags that I would like to show the entire contents in IE. I’ve looked around and found a few fixes, but I don’t want to include YUI since I’m already using jQuery elsewhere, and would prefer to keep the selects on the page instead of replacing it with DIVs.

In the code that I’ve come up with, FF3 works great. In Internet Explorer (6,7,8) the first click on the <select> flashes the drop down and then it disappears. I’ve tried focus and mousedown in place of the click event in the code, no success.

If I remove both of the setting of element.css in autoWidth the drop downs work as expected, without the bonus of having a nice width. Does anyone know what would cause the setting of the css to make the drop down fail in IE?

<head>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
 <script type="text/javascript">
 var count = 0;
 autoWidth = function(e) {
  $element = $(e.target)
  $element.css("width","auto");
  if($element.width() < $element.data("originalWidth"))
  {
   $element.css("width", $element.data("originalCSSWidth"));
  }
 }
 resetWidth = function(e) {
  $element = $(e.target)
  $element.css("width", $element.data("originalCSSWidth"));
  $("#counter").text(++count);
 }
 recordEvent = function(e) {
  $("#event").text($("#event").text() + " " + e.type);
 }
 dropDownIEWidthFix = function() {
 //if($.browser.msie)
 //{
  $dropDown = $(this);
  $dropDown.data("originalWidth", $dropDown.width());
  $dropDown.data("originalCSSWidth", $dropDown.css("width"));
  $dropDown.blur(recordEvent);
  $dropDown.blur(resetWidth);
  $dropDown.change(recordEvent);
  $dropDown.change(resetWidth);
  $dropDown.click(recordEvent);
  $dropDown.click(autoWidth);
 //}
 };
 $(function() {
  $("select.officeItemList").each(dropDownIEWidthFix);
 });
 function trackingSelectionChanged(select)
 {
  $("#event").text($("#event").text() + " inlineOnChange");
 }
 </script>
</head>
<body>
 <div style="overflow:hidden;width:148px;">
  <select class="officeItemList" style="width:148px;" onchange="trackingSelectionChanged(this);">
   <option value="1">erasersdffffffffffeeefefsdfsdfsdfsdfsdfsdfsdfsdfsdfdsfsdfefesf</option>
   <option value="3">pencil</option>
   <option value="4">ruler</option>
   <option value="5">ink</option>
   <option value="7">A4 paper</option>
   <option value="8">A3 paper</option>
   <option value="9">erasersdffffffffffeeefefsdfsdfsdfsdfsdfsdfsdfsdfsdfdsfsdfefesf</option>
   <option value="10">executive</option>
   <option value="11">janitor</option>
   <option value="12">developer</option>
  </select>
 </div>
 <div style="overflow:hidden;width:160px;">
  <select class="officeItemList" style="width:160px;" onchange="trackingSelectionChanged(this);">
   <option value="3">pencil</option>
   <option value="4">ruler</option>
   <option value="5">ink</option>
   <option value="7">A4 paper</option>
   <option value="8">A3 paper</option>
   <option value="9">erasersdffffffffffeeefefsdfsdfsdfsdfsdfsdfsdfsdfsdfdsfsdfefesf</option>
   <option value="10">executive</option>
   <option value="11">janitor</option>
   <option value="12">developer</option>
  </select>
 </div>
 <div style="overflow:hidden;width:160px;">
  <select class="officeItemList" style="width:160px;" onchange="trackingSelectionChanged(this);">
   <option value="1">eee</option>
   <option value="3">pencil</option>
   <option value="4">ruler</option>
   <option value="5">ink</option>
   <option value="7">A4 paper</option>
   <option value="8">A3 paper</option>
   <option value="9">ffff</option>
   <option value="10">executive</option>
   <option value="11">janitor</option>
  </select>
 </div>
 <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
 AdjustWidth fired :<span id="counter"></span> times
 <div id="event"></div>
</body>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:53:39+00:00Added an answer on May 12, 2026 at 5:53 pm

    Looks like the problem is with IE’s rendering of the drop downs. If you change the css on the <select> the drop down gets reset (the flicker on initial click).

    So, using the mousedown event instead of click fixes the first two drop downs, but because of the additional reset on the third drop down (since it is large enough already) breaks IE’s native change event (the drop down value never changes regardless of what options you click).

    Solution: On the initial page load – don’t bind the events if the drop down is large enough already. I switched the width to auto, and measured the <select>, then only bind the width change events when the drop downs need it, you can avoid the events to the other drop downs.

    Here is the code- tested IE 6,7,8. FireFox works correctly to begin with, same with Safari.
    You can see a line commented with IE6 fix, this line, when removed, causes the original (incorrect) behavior in IE6. To be honest, I’m not sure why.

    <head>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>  
            <script type="text/javascript">
    dropDownIEWidthFix = function() {
    if($.browser.msie) {
        $dropDown = $(this);
        $dropDown.data("originalWidth", $dropDown.width());
        $dropDown.data("originalCSSWidth", $dropDown.css("width"));
        $dropDown.css("width", "auto");
        if($dropDown.width() > $dropDown.data("originalWidth")) {
            $dropDown.blur(function(e) {
                $element = $(e.target);
                $element.css("width", $element.data("originalCSSWidth"));
            });
            $dropDown.change(function(e) {
                $element = $(e.target);
                $element.css("width", $element.data("originalCSSWidth"));
            });
            $dropDown.mousedown(function(e) {
                $element = $(e.target);
                $element.css("width","auto");
                $element.width(); //IE6 fix.
            });
        }
        $dropDown.css("width", $dropDown.data("originalCSSWidth"));
    }}
    $(function() {
        $("select.officeItemList").each(dropDownIEWidthFix);
    });
    function trackingSelectionChanged(select)
    {
    }
    </script>
    </head>
    <body>
        <div style="float: left; display: inline; width: 160px;">
            <div class="FUNCOptionTitle">
                <span style="text-align: right;">col1</span>
            </div>
            <div style="overflow:hidden;width:148px;">
                <select class="officeItemList" style="width:148px;" onchange="trackingSelectionChanged(this);">
                    <option value="1">erasersdffffffffffeeefefsdfsdfsdfsdfsdfsdfsdfsdfsdfdsfsdfefesf</option>
                    <option value="3">pencil</option>
                    <option value="4">ruler</option>
                    <option value="5">ink</option>
                    <option value="7">A4 paper</option>
                    <option value="8">A3 paper</option>
                    <option value="9">erasersdffffffffffeeefefsdfsdfsdfsdfsdfsdfsdfsdfsdfdsfsdfefesf</option>
                    <option value="10">executive</option>
                    <option value="11">janitor</option>
                    <option value="12">developer</option>
                </select>
            </div>
        </div>
        <div style="float: left; display: inline; width: 165px;">
            <div class="FUNCOptionTitle">
                <span style="text-align: right;">col2</span>
            </div>
            <div style="overflow:hidden;width:160px;">
                <select class="officeItemList" style="width:160px;" onchange="trackingSelectionChanged(this);">
                    <option value="3">pencil</option>
                    <option value="4">ruler</option>
                    <option value="5">ink</option>
                    <option value="7">A4 paper</option>
                    <option value="8">A3 paper</option>
                    <option value="9">erasersdffffffffffeeefefsdfsdfsdfsdfsdfsdfsdfsdfsdfdsfsdfefesf</option>
                    <option value="10">executive</option>
                    <option value="11">janitor</option>
                    <option value="12">developer</option>
                </select>
            </div>
        </div>
        <div style="float: left; display: inline; width: 165px;">
            <div class="FUNCOptionTitle">
                <span style="text-align: right;">col3</span>
                </div>
            <div style="overflow:hidden;width:160px;">
                <select class="officeItemList" style="width:160px;" onchange="trackingSelectionChanged(this);">
                    <option value="1">eee</option>
                    <option value="3">pencil</option>
                    <option value="4">ruler</option>
                    <option value="5">ink</option>
                    <option value="7">A4 paper</option>
                    <option value="8">A3 paper</option>
                    <option value="9">ffff</option>
                    <option value="10">executive</option>
                    <option value="11">janitor</option>
                </select>
            </div>
        </div>
        <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
        AdjustWidth fired :<span id="counter"></span> times
        <div id="event"></div>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.