-1

Possible Duplicate:
height of the dropdown box display

hi

how can I adjust the height of the list in the dropdown because I have too many values loaded in the drop down box. For example, it only show 10 entries, and with scrollbars to see remaining. does anyone know how to do that?


this not what I want this is not what I want


I want this ,which only display 5 option and with scrollbars to see remaining I want this ,which only display 5 option and with scrollbars to see remaining

Community
  • 1
  • 1
tian
  • 25
  • 1
  • 5

2 Answers2

1

Do you mean?:

 <select size="234">
Tobbe Brolin
  • 455
  • 1
  • 3
  • 13
  • 1
    no that's not what I want. if I set the size ="a number", the option will display a number of value in fix, which it wouldn't Collapse. I am sorry to my poor english. you may understand what I mean with the pictures that I attached – tian Apr 08 '11 at 21:27
1

Use the following code:

<select size="10" id="items">
    <option value="a1">A1</option>
    <option value="b1">B1</option>
    <option value="c1">C1</option>
    <option value="d1">D1</option>
    <option value="e1">E1</option>
    <option value="a2">A2</option>
    <option value="b2">B2</option>
    <option value="c2">C2</option>
    <option value="d2">D2</option>
    <option value="e2">E2</option>
</select>

Where 10 is the number of items to show at one time. Be sure to be considerate of people with small resolutions who may not be able to see all of the items if you make it too large. Please consult the following link for more information about this setting:

http://www.w3schools.com/tags/att_select_size.asp

EDIT:

The above code will make the select look like a list box. You cannot control the size of the select object and still keep it looking the same. Because it is an application level control, the web browser renders it and does not allow for this setting. For more information, see the following Stack Overflow page that features the same question:

Height of an HTML select box (dropdown)

Community
  • 1
  • 1
Devin Burke
  • 13,642
  • 12
  • 55
  • 82
  • no that's not what I want. if I set the size ="a number", the option will display a number of value in fix, which it wouldn't Collapse. I am sorry to my poor english. you may understand what I mean with the pictures that I attached. – tian Apr 08 '11 at 21:22
  • 1
    I edited my solution. Basically, you cannot do what you are trying to do. You would have to create your own custom drop down using pure JavaScript. – Devin Burke Apr 08 '11 at 21:42