I want to have a element that displays in the multiple selection display style (it --the box instead of the drop down), but only allows you to select on thing at a time. Is that possible?
This will display a listbox-style select element that allows only one selected item at a time:
<select size="3">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
The size
atttribute will control how many rows that are visible in the control. If you want to allow multiple items to be selected, add the multiple attribute to the select element:
<select size="3" multiple="multiple">
The manner in which SELECT elements are rendered is implementation-dependent. The fact that in most browsers 'multiple="1"' gets you a (possibly scrolling) box of options and multiple="0" gets you a drop-down box is coincidence.
There is no standard for saying "I want a list box that only allows one option to be selected".
See also:
http://www.w3.org/TR/html401/interact/forms.html#h-17.6
You could write js that would deselect any extra selections onclick
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With