I have a <SELECT multiple>
field with multiple options and I want to allow it to have only one option selected at the same time but user can hold CTRL key and select more items at once.
Is there any way how to do it? (I don't want to remove 'multiple').
Why don't you want to remove the
multiple
attribute? The entire purpose of that attribute is to specify to the browser that multiple values may be selected from the givenselect
element. If only a single value should be selected, remove the attribute and the browser will know to allow only a single selection.Use the tools you have, that's what they're for.
If the user should select only one option at once, just remove the "multiple" - make a normal select:
Fiddle
I am coming here after searching google and change thing at my-end.
So I just change this sample and it will work with jquery at run-time.
http://jsfiddle.net/ajayendra2707/ejkxgy1p/5/
Just don't make it a select multiple, but set a size to it, such as:
Working example: https://jsfiddle.net/q2vo8nge/
This simple solution allows to obtain visually a list of options, but to be able to select only one.
You want only one option by default, but the user can select multiple options by pressing the CTRL key. This is (already) exactly how the SELECT multiple is meant to behave.
See this: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select_multiple
Can you please clarify your question?