jQuery Editable Select is a jQuery plugin that transforms a select into an input field where single elements are shown in real-time according to the entered characters. It scales down to a real select list when javascript is not available.
See demos here.
<select id="editable-select">
<option>Alfa Romeo</option>
<option>Audi</option>
<option>BMW</option>
<option>Citroen</option>
<option>Fiat</option>
<option>Ford</option>
<option>Jaguar</option>
<option>Jeep</option>
<option>Lancia</option>
<option>Land Rover</option>
<option>Mercedes</option>
<option>Mini</option>
<option>Nissan</option>
<option>Opel</option>
<option>Peugeot</option>
<option>Porsche</option>
<option>Renault</option>
<option>Smart</option>
<option>Volkswagen</option>
<option>Volvo</option>
</select>
$('#editable-select').editableSelect();
The default text showed right after the initialization.
<select id="editable-select">
<option>Alfa Romeo</option>
<option selected>Audi</option>
<option>BMW</option>
</select>
All HTML tags will be shown after the rendering of the list.
<select id="editable-select">
<option>Alfa Romeo - <small><a href="http://www.alfaromeo.com/">www.alfaromeo.com</a></small></option>
<option>Audi - <small><a href="http://www.audi.com/">www.audi.com</a></small></option>
<option>BMW - <small><a href="http://www.bmw.com/">www.bmw.com</a></small></option>
<option>Citroen - <small><a href="http://www.citroen.com/">www.citroen.com</a></small></option>
<option>Fiat - <small><a href="http://www.fiat.com/">www.fiat.com</a></small></option>
<option>Ford - <small><a href="http://www.ford.com/">www.ford.com</a></small></option>
<option>Jaguar - <small><a href="http://www.jaguar.com/">www.jaguar.com</a></small></option>
<option>Jeep - <small><a href="http://www.jeep.com/">www.jeep.com</a></small></option>
<option>Lancia - <small><a href="http://www.lancia.com/">www.lancia.com</a></small></option>
<option>Land Rover - <small><a href="http://www.landrover.com/">www.landrover.com</a></small></option>
<option>Mercedes - <small><a href="http://www.mercedes-benz.com/">www.mercedes-benz.com</a></small></option>
<option>Mini - <small><a href="http://www.mini.com/">www.mini.com</a></small></option>
<option>Nissan - <small><a href="http://www.nissan.it/">www.nissan.it</a></small></option>
<option>Opel - <small><a href="http://www.opel.com/>www.opel.com</a></small></option>
<option>Peugeot - <small><a href="http://www.peugeot.com/">www.peugeot.com</a></small></option>
<option>Porsche - <small><a href="http://www.porsche.com/">www.porsche.com</a></small></option>
<option>Renault - <small><a href="http://www.renault.com/">www.renault.com</a></small></option>
<option>Smart - <small><a href="http://www.smart.com/">www.smart.com</a></small></option>
<option>Volkswagen - <small><a href="http://volkswagen.com/">volkswagen.com</a></small></option>
<option>Volvo - <small><a href="http://www.volvo.com/">www.volvo.com</a></small></option>
</select>
If the height of the list rises above 160px, a scrollbar is displayed.
You can change the max-height of the list box by css:
.es-list { max-height: 160px !important; }
Boolean. Default: 'true'
Filter or not items in list while typing.
$('#editable-select').editableSelect({ filter: true });
String. Default: 'default'
A string indicating which effect to use for the transition.
- default
- slide
- fade
$('#editable-select').editableSelect({ effects: 'slide' });
Integer or string. Default: 'fast'
A string or number determining how long the animation will run.
- fast
- slow
- [0-9]+
$('#editable-select').editableSelect({ duration: 200 });
Fired when the input is intialized.
$('#editable-select').editableSelect({
onCreate: function () {
alert("Initialized!");
}
});
Fired when the list is shown.
$('#editable-select').editableSelect({
onShow: function () {
alert("Visible!");
}
});
Fired when the list is hidden.
$('#editable-select').editableSelect({
onHide: function () {
alert("Hidden!");
}
});
Fired when an option of the list is selected.
$('#editable-select').editableSelect({
onSelect: function (element) {
alert("Selected!");
}
});
The jQuery Editable Select includes some keyboard navigation:
You can navigate through list with keyboard arrows.
When the list is visible, enter will select one option and replace the input with that text.
When the list is not visible, enter will have normal behavior (submitting the current form, etc...)
The tab key hides the list.
The escape key hides the list.