I am trying to create a simple area and zip code search app. The app works and the listview is populated with the user input. However, the listview is only populated once the full name of the area is entered by user. I want it to autocomplete and list suggestions as the user types in the search box.
<div class="searcharea">
<input id="valueEnter1" oninput="searchme(this)" />
<ul data-role="listview" data-inset="false" data-filter="true" data-filter-reveal="true" data-input="#valueEnter1" id="valueId1"></ul>
function searchme(object) {
$("#valueId1").empty();
var valueId1= "";
var valueIdName1= $("#valueEnter1").val();
if (valueIdName1.length > 2) {
var select = '%' + valueIdName1+ '%';
db.transaction(function (transaction) {
transaction.executeSql('SELECT * FROM location WHERE suburb LIKE "' + valueIdName+ '";', [],
function (transaction, results) {
if (results != null && results.rows != null) {
if (results.rows.length > 0) {
for (var i = 0; i < results.rows.length; i++) {
var code0 = results.rows.item(i).suburb;
var code1 = results.rows.item(i).area;
var code2 = results.rows.item(i).postal_code;
var code3 = results.rows.item(i).zip;
valueId1+= '<li data-filtertext="' + code0 + '"><a href="#">' + code0 + '</br> ' + code1 + '</br> ' + code2 + ' ' + code3 + '</a></li>'
}
$("#valueId1").append(valueId1).selectmenu('refresh');
}
}
});
});
}
}
What is needed to use autocomplete while using sqlite database? I have a pre populated database(areas.db) located in my www folder.