hello,
i have this google auto complete it works fine i want to change some thing when user type in textbox1 and google places shows suggestion after selection result should show in textbox3
same for text2 google place in txtbox2 and after selection result should show in text4
please advice
var textbox3 = $(this).find('[id*=txtfrom]');
var textbox1 = $(this).find('[id*=txosearch]');
<script type="text/javascript">
var fromAddress;
var toAddress;
$(function () {
var textbox1 = $(this).find('[id*=txosearch]');
var textbox2 = $(this).find('[id*=txtosearch]');
var textbox3 = $(this).find('[id*=txtfrom]');
var textbox4 = $(this).find('[id*=txtto]');
ApplyAutoComplete(textbox1);
ApplyAutoComplete(textbox2);
$(textbox1).blur(function () {
var address = $(this).val();
if (address == fromAddress) {
//$('[id*=lblFrom]').hide();
this.textbox1.val("");
} else {
//$('[id*=lblFrom]').show();
this.textbox1.val("");
}
});
$(textbox2).blur(function () {
var address = $(this).val();
if (address == toAddress) {
//$('[id*=lblTo]').hide();
this.textbox1.val("");
} else {
//$('[id*=lblTo]').show();
this.textbox2.val("");
}
});
});
function ApplyAutoComplete(input) {
google.maps.event.addDomListener(window, 'load', function () {
var places;
for (var i = 0; i < input.length; i++) {
var options = { types: ['(regions)'] };
places = new google.maps.places.Autocomplete(input[i], options);
}
google.maps.event.addListener(places, 'place_changed', function () {
if ($(input)[0].id == $('#<%=txtfrom.ClientID%>')[0].id) {
fromAddress = places.getPlace().formatted_address;
$('[id*=txtfrom]').val(fromAddress);
$('[id*=txtfrom]').trigger("blur");
} else if ($(input)[0].id == $('#<%=txtto.ClientID%>')[0].id) {
toAddress = places.getPlace().formatted_address;
$('[id*=txtto]').val(toAddress);
$('[id*=txtto]').trigger("blur");
}
});
});
};
</script>