0

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?

Mat
  • 202,337
  • 40
  • 393
  • 406
Thomas
  • 1
  • 1
  • 1

2 Answers2

1

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
  • 2,283
  • 1
  • 15
  • 18
  • Hi Tom, It must allow for multiple items to be selected at once, not just one. – Thomas Dec 09 '09 at 09:42
  • Ah, sorry. I don't know of any possibility to achieve this using standard HTML. – Tom Bartel Dec 09 '09 at 09:44
  • Then you should set multiple="multiple" for – Deniss Kozlovs Dec 09 '09 at 09:44
  • My vision of such a thing would be perhaps a – Thomas Dec 09 '09 at 09:46
  • 1
    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 Dec 09 '09 at 10:50
  • `size="1"` works and will result in a select with a height of 1 as expected. It's not super usable but it is usable as you can still scroll through the options and select them. Personally I've used it to keep things visually aligned when JS isnt loaded – Paul Odeon Aug 08 '21 at 09:08
1

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.

Community
  • 1
  • 1
Andy Mikhailenko
  • 1,571
  • 1
  • 11
  • 10