views:

440

answers:

3

Is there any way of creating a combo box (<select>) with a size of 1? All the examples I can find allow for multiple selects but with a number of options visible at any one time. If this cannot be accomplished with bog standard HTML is it possible in a JS library such as JQuery?

A: 

EDIT: My post does not answer the question, but the comments might clarify the question.

What you want is to set the attribute size to 1, i.e.:

<select size="1" name="...">
    <option value="...">...</option>
    ...
</select>
Tom Bartel
Hi Tom,It must allow for multiple items to be selected at once, not just one.
Thomas
Ah, sorry. I don't know of any possibility to achieve this using standard HTML.
Tom Bartel
Then you should set multiple="multiple" for <select> and height:xx i guess
Deniss Kozlovs
My vision of such a thing would be perhaps a <select> that you click that drops down a whole bunch of items allowing you to click the ones you like with the menu "closing" when the user clicks elsewhere. Doesn't look to be possible does it? Sounds like I might need to look into creating a custom combo box although I'm not quite sure where to begin with that.
Thomas
How about a list of checkboxes inside a div? You could have the div slide down when some event happens, and slide up again when you don't need it any more. If you think this could work for you, you could have a look at qtip (http://craigsworks.com/projects/qtip/).
Tom Bartel
+1  A: 

I'm afraid that would be usability nightmare. What is the more general goal you are trying to achieve? I'm sure better solutions already exist.

I could guess you need something like tag editor widget.

Andy Mikhaylenko
A: 

For the record, you can pass a size parameter to a multiple select like this:

<?=$form->input('FieldName', array(
    'size' => '5'
)); ?>

This is especially useful when you have long lists of HABTM related records.

Federico B.