This is almost the same answer as Vevik, but a just-adjusted version of what I really wanted and tried to do. I tested it.
<html> <head> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script> $(function(){ var data = [{ "id": 1, "name": "JAVA" }, { "id": 2, "name": "cake PHP" }, { "id": 3, "name": "Android" }]; var data_labels = []; var data_dictionay = []; $.each(data, function(index, _data) { data_labels.push(_data.name); data_dictionay[_data.name] = _data.id; }); $('#search').autocomplete({ source : data_labels, select: function(ui, item) { if(data_dictionay[item.item.value]){ window.location = "/home/view/" + data_dictionay[item.item.value]; } } }); }); </script> </head> <body> <input id="search" type="text"> </body> </html>
source share