I use the js library select2. This is a screenshot of what I have now:
Start:
Click on dropdown:
Now is it possible to have an input field to start with and not directly a dropdownlist? I know it's possible because you can find it on the select2 site. An example is this:
But the documentation is very brief. This is what I have now:
<input type="text" name="questions[question1]" id="question1" class="question1" style="width:500px"/>
function createQuestionTags(data, question_number){
$(".question" + question_number).select2({
createSearchChoice: function (term, data) {
if ($(data).filter(function () {
return this.text.localeCompare(term) === 0;
}).length === 0) {
return {
id: term,
text: term
};
}
},
data: data,
placeholder: "Enter Question",
allowClear:true
});
}
(The data is received from an ajax call)
The only workaround that I could come up with is to use both
multiple: true
andmaximumSelectionSize: 1
when setting up.Please see my example here: http://jsfiddle.net/DanEtchy/Lnf8j/
Instead of
Select2
the better choice would beselectize
becauseSelect2
seems deadThe usage is easy:
Here is number of examples how to use and customize
selectize
Matt,)
this work