//Getting Place Name from Location DB
$(function () {
$("#fromloc_").on("input", function () {
if ($("#fromloc_").val() != "") {
getAutoComplete($("#fromloc_").val());
}
});
$("#toloc_").on("input", function () {
if ($("#toloc_").val() != "") {
getAutoComplete1($("#toloc_").val());
}
});
});
function getAutoComplete(PlaceName) {
var uri = "AddBooking/GetPlace";
$.getJSON(uri, { PlaceName: PlaceName }).done(function (data) {
$('ul#lst').html("");
var count = 0;
$.each(data, function (key1, item1) {
var li = $('<li/>').addClass('ui-menu-item1')
.html("<a style='color:black' onclick=\"setText('" + item1 + "')\">" + item1 + "</a>")
.appendTo($('ul#lst'));
count++;
});
});
}
function getAutoComplete1(PlaceName1) {
var uri1 = "AddBooking/GetPlace1";
$.getJSON(uri1, { Place: PlaceName1 }).done(function (data) {
$('ul#lst1').html("");
var count = 0;
$.each(data, function (key2, item2) {
var lis = $('<li/>').addClass('ui-menu-item2')
.html("<a style='color:black' onclick=\"setText1('" + item2 + "')\">" + item2 + "</a>")
.appendTo($('ul#lst1'));
count++;
});
});
}
function setText(text) {
$("#fromloc_").val(text);
$(".ui-menu-item1").hide();
GetFromLocLatLon($("#fromloc_").val());
}
function setText1(text) {
$("#toloc_").val(text);
$(".ui-menu-item2").hide();
GetToLocLatLon($("#toloc_").val());
//alert(textbox1.val());
}
Here i'm using two textboxes fromloc and toloc..it will shows place name auto suggest from Database..i need to toggle the key up/down for chossing place name .. onlick event only working on that anchor tag..