morena Posted December 15, 2016 Share Posted December 15, 2016 (edited) good day, i have a programme built in php and html which i want to incorporate a searcheble dropdown menu in it,i found this link on how to do it using jquery http://jsearchdropdown.sourceforge.net/ but the problem is that one used option tags around all of thier options, which is something i can not do because my dropdown will hold around 70000 options. here is my php code: <?phpinclude_once 'dbConfig.php';$query="SELECT * FROM medications";$result= $con->query($query);?> <select id="nol" style="width: 40%;" name="disease" required="true" data-toggle="tooltip" data-original-title="medications" class="date-picker form-control col-md-7 col-xs-12" data-rel="chosen"><option value="">Select Disease</option><?php while ($row=$result->fetch_array(MYSQLI_ASSOC)) { ?><option value="<?php echo $row['ICD10']?>"><?php echo $row['diagnosis'];?> </option> <?php } ?> </select> so what i need help with to be make that dropdown have a search feature or function but do not know how to doit, also because the data in the dropdown is being populated from the database not hard coded in html as options Edited December 15, 2016 by morena Quote Link to comment Share on other sites More sharing options...
Barand Posted December 15, 2016 Share Posted December 15, 2016 Instead of a list of 70,000 items it sounds like you might need some sort of cascading selection. So you first select a category, which gives you a list of sub-categories Then select a sub-category which can then give you another shorter list. ... and so on until you have narrowed the options down to a manageable sized list. The way to accomplish this is with AJAX, passing the category and receiving the shorter list etc. Quote Link to comment Share on other sites More sharing options...
benanamen Posted December 15, 2016 Share Posted December 15, 2016 (edited) What you are looking for is called "Auto Complete". It is the same thing google does. It uses AJAX. Google is your friend. I easily found numerous examples. There is no need split the data unless you want to get results by category like @Barand said. The only thing with categories is a medicine can fall into numerous categories. If you do not have that all mapped the user may have trouble drilling down to a specific medicine. A single autocomplete is best if they already know the name of the medicine. You may actually want both options, one if you know the name, the chained select if you are trying to find a type of medicine. https://www.google.com/search?q=php+autocomplete+dropdown+from+database Edited December 15, 2016 by benanamen Quote Link to comment Share on other sites More sharing options...
morena Posted December 15, 2016 Author Share Posted December 15, 2016 @ benanamen thank you, thats what i am actually looking for, i will check it out @Barand thank you for your sugesstion too. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.