I have a inputfield which has a large (10000 items) datalist as a autocomplete source. The datalist is generated dynamically from serverside.
<input type="text" name="medicine" required="" list="list__medicine-list" id="id_medicine" class="form-input mb-4">
<datalist id="list__medicine-list">
<option value="1stCef (Cefadroxil Monohydrate)" medicine_id="1"></option>
<option value="2ndCef (Cefaclor Monohydrate)" medicine_id="2"></option>
<option value="3-C (Cefixime Trihydrate)" medicine_id="3"></option>
<!-- -->
<!-- -->
<!-- -->
<option value="Zinc (Zinc Sulphate)" medicine_id="11303"></option>
</datalist>
I can type in the inputfield and it will autocomplete using the typed characters. But it will match in the middle and not sort the datalist according to what I have typed in the inputfield.
I want to sort the datalist items so that It will show the matched initial letters (For the example image, it will bring the Zinc Sulphate to the top). How can I do this without using an ajax call to the server using custom javascript?