Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Two Vertical Scrollbars in select and DIC

Question posted by: aswinm (Newbie) on April 2nd, 2008 12:49 PM
Hi All,

I have a sample page in which I am enclosing a <Select within a DIV, The purpose is to have a horizontal scrollbar for the <Select. The page is working perfectly fine. But I notice that when the no of items in the <select is increasing many fold, the listbox is displaying its own scrollbar, even though the DIV is having space, resulting in two scrollbars. I am Unable to figure out why it is happening like this. If I reduce the font size, then the list is able to accomodate a few more entries. For ur reference I am attaching the code below.

Please copy paste the options to more than 2000 items. The problem will come up.

Thanx in Advance.
Code: ( text )
  1. <html>
  2. <head><title> Testing select option</title>
  3. <script language="javascript">
  4. function OnDivSrcScroll()
  5. {
  6.     if (SourceAccounts.options.length > 17)
  7.     {
  8.         SourceAccounts.size=SourceAccounts.options.length; 
  9.     }
  10.     else
  11.     {
  12.         SourceAccounts.size=17;
  13.     }
  14. }
  15.  
  16. function OnSrcSelectFocus()
  17. {
  18.  
  19.     if (document.getElementById("divSrcAccounts").scrollLeft != 0)
  20.     {
  21.         document.getElementById("divSrcAccounts").scrollLeft = 0;
  22.     }
  23.  
  24. }
  25. </script>
  26. </head>
  27. <body>
  28.  
  29.   <br><BR><HR>
  30.   Please Choose
  31.    <div id='divSrcAccounts'
  32.     style="overflow:auto;position: relative;width:300px;HEIGHT: 233px;"
  33.   onscroll="OnDivSrcScroll();" >
  34.  
  35. <SELECT size="17"
  36.                                                     name="SourceAccounts"  multiple onfocus="OnSrcSelectFocus();" >
  37.  
  38.                                                     <OPTION value="003000109">003000109&nbsp;&nbsp;&nbsp;FCIA DEL PUEBLO</OPTION>
  39.  
  40.                                                     <OPTION value="003000133">003000133&nbsp;&nbsp;&nbsp;FCIA DEL CARMEN *OROCOVIS*GNP*</OPTION>
  41.  
  42.                                                     <OPTION value="003000158">003000158&nbsp;&nbsp;&nbsp;U-SAVE PHARMACY L.L.C. *GNP*</OPTION>
  43.  
  44.                                                     <OPTION value="003000182">003000182&nbsp;&nbsp;&nbsp;FCIA NUEVA,JM PHA GRP INC*GNP*</OPTION>
  45.  
  46.                                                     <OPTION value="003000109">003000109&nbsp;&nbsp;&nbsp;FCIA DEL PUEBLO</OPTION>
  47.  
  48.                                                     <OPTION value="003000133">003000133&nbsp;&nbsp;&nbsp;FCIA DEL CARMEN *OROCOVIS*GNP*</OPTION>
  49.  
  50.                                                     <OPTION value="003000158">003000158&nbsp;&nbsp;&nbsp;U-SAVE PHARMACY L.L.C. *GNP*</OPTION>
  51.  
  52.                                                     <OPTION value="003000182">003000182&nbsp;&nbsp;&nbsp;FCIA NUEVA,JM PHA GRP INC*GNP*</OPTION>
  53.                                                     <OPTION value="003000109">003000109&nbsp;&nbsp;&nbsp;FCIA DEL PUEBLO</OPTION>
  54.  
  55.                                                     <OPTION value="003000133">003000133&nbsp;&nbsp;&nbsp;FCIA DEL CARMEN *OROCOVIS*GNP*</OPTION>
  56.  
  57.                                                     <OPTION value="003000158">003000158&nbsp;&nbsp;&nbsp;U-SAVE PHARMACY L.L.C. *GNP*</OPTION>
  58.  
  59.                                                     <OPTION value="003000182">003000182&nbsp;&nbsp;&nbsp;FCIA NUEVA,JM PHA GRP INC*GNP*</OPTION>
  60.                                                     <OPTION value="003000109">003000109&nbsp;&nbsp;&nbsp;FCIA DEL PUEBLO</OPTION>
  61.  
  62.                                                     <OPTION value="003000133">003000133&nbsp;&nbsp;&nbsp;FCIA DEL CARMEN *OROCOVIS*GNP*</OPTION>
  63.  
  64.                                                     <OPTION value="003000158">003000158&nbsp;&nbsp;&nbsp;U-SAVE PHARMACY L.L.C. *GNP*</OPTION>
  65.  
  66.                                                     <OPTION value="003000182">003000182&nbsp;&nbsp;&nbsp;FCIA NUEVA,JM PHA GRP INC*GNP*</OPTION>
  67.  
  68.                                                 </SELECT>
  69.  
  70.  
  71. </div>
  72. </body>
  73. </html>
Last edited by drhowarddrfine : April 2nd, 2008 at 03:42 PM. Reason: Please use code tags
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
jhardman's Avatar
jhardman
Moderator
2,050 Posts
May 14th, 2008
09:54 PM
#2

Re: Two Vertical Scrollbars in select and DIC
Code: ( text )
  1. style=" height: 233px;
  2.     width: 295px;
  3.     overflow: scroll;"
This style attribute in the code in the select (and eliminate the div) should do everything you want, but I checked in both FF and IE, and neither one worked. Sorry. Are you still looking for a solution?

Jared

Reply
Reply
Not the answer you were looking for? Post your question . . .
174,847 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top HTML / CSS Forum Contributors