views:

975

answers:

3

Can you do it programmatically?

+2  A: 

I may be wrong, but I don't believe that is possible with the default select box. You could do something with JS & CSS that achieves the desired result, but not (to my knowledge) the vanilla SELECT.

Chuck
+3  A: 

You can't do this with a HTML select tag, but you can do it with JavaScript and HTML. There are variety of existing controls that do this - for instance, the "suggest" list attached to the SO "interesting/ignored tag" entry, or Gmail's lookup for email adresses.

There are many JavaScript+HTML controls that provide this capability--look for autocomplete controls for ideas.

See this link for one control... http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx

rp
+7  A: 

This is the closest I could get, change the size of the element onmouseover, and restore the size onmouseout:

   <select onMouseOut="this.size=1;" onMouseOver="this.size=5;">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
  </select>
CMS
or<SELECT onMouseOut="this.size=1;" onMouseOver="this.size=this.length;">...</SELECT>
RealHowTo