I want to create a search for a multi-select but i have no idea where to start.
I'd want the search to remove all the other options and only show the one that matches the search(the search would go through each word(first name, last name, and also username) excepting email.
I'd create the event listener on the keyup but after that I literally have no idea on how to continue.
This is how my select looks like:
$("#addselect_searchtext").keyup(function() {
alert("do_search?");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="span5">
<label for="addselect">Users</label>
<div class="userselector" id="addselect_wrapper">
<select name="addselect" id="addselect" size="20" class="form-control" style="">
<optgroup id="toexec" label="All Students (2)">
<option value="2">Admin User (admin, andrei@yahoo.com)</option>
<option value="3">Student Test (student, studenttest@mailinator.com</option>
</optgroup>
</select>
<div class="form-inline">
<label for="addselect_searchtext">Search</label><input type="text" name="addselect_searchtext" id="addselect_searchtext" size="15" value="" class="form-control"><input type="button" value="Clear" class="btn btn-secondary m-x-1" id="addselect_clearbutton"
disabled=""></div>
</div>
</div>