select 2 multiselect dropdown example
Example 1: html select multiple
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/harvesthq/chosen/gh-pages/chosen.jquery.min.js"></script>
<link href="https://cdn.rawgit.com/harvesthq/chosen/gh-pages/chosen.min.css" rel="stylesheet"/>
<form action="http://httpbin.org/post" method="post">
<select data-placeholder="Begin typing a name to filter..." multiple class="chosen-select" name="test">
<option value=""></option>
<option>American Black Bear</option>
<option>Asiatic Black Bear</option>
<option>Brown Bear</option>
<option>Giant Panda</option>
<option>Sloth Bear</option>
<option>Sun Bear</option>
<option>Polar Bear</option>
<option>Spectacled Bear</option>
</select>
<input type="submit">
</form>
Example 2: multiple search selection dropdown
<div class="row">
<div class="col-md-12">
<select class="mdb-select colorful-select dropdown-primary md-form" multiple searchable="Search here..">
<option value="" disabled selected>Choose your country</option>
<option value="1">USA</option>
<option value="2">Germany</option>
<option value="3">France</option>
<option value="4">Poland</option>
<option value="5">Japan</option>
</select>
<label class="mdb-main-label">Label example</label>
<button class="btn-save btn btn-primary btn-sm">Save</button>
</div>
</div>
Example 3: select 2 multiselect
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script>
$(document).ready(function() {
$('.js-example-basic-single').select2();
});
Example 4: select 2 dropdown
$('#element').select2({
placeholder: 'Select a option',
minimumInputLength: 3,
ajax: {
url: route('api.fetch-options'),
dataType: 'json',
type: 'GET',
quietMillis: 50,
data: function (params) {
return {
visitor_name: params.term
}
},
processResults({ data }) {
return {
results: $.map(data, function (item) {
return {
text: item.name,
id: item.id,
}
})
}
}
}
}).change(() => {
});