How to pass address value using dropdown control in java script
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
venky n115 reputationPosted Mar 12, 2015, 3:02 AM EDT
Lucky Laxman92 reputationPosted Mar 12, 2015, 1:34 AM EDT
you can use like this if any error you get , replay the error.
$(document).ready(function () {
$("#ddcity").change(function () {
var city = $("#ddcity").val();
var geocoder = new google.maps.Geocoder();
// Their ( con ) this varaible where your getting i dont know . your drop down value come above given like that.
var com = city + "," + con;
geocoder.geocode({ 'address': com }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var x = results[0].geometry.location.lat();
var y = results[0].geometry.location.lng();
var latlng = new google.maps.LatLng(x, y);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map($("#map-canvas").val(), myOptions);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(x, y),
map: map,
title: com
});
var infowindow = new google.maps.InfoWindow({
content: com
});
infowindow.open(map, marker);
google.maps.event.addDomListener(window, 'load');
} else {
res.innerHTML = "Enter correct Details: " + status;
}
});
});
});
if it use full like Me
Thanks,
venky n115 reputationPosted Mar 12, 2015, 1:43 AM EDT
the map can't visible the runtime.the same coding successfully executed in button control but not executing in dropdown control.plz help me sir
venky n115 reputationPosted Mar 12, 2015, 1:45 AM EDT
con means country another one textbox name but not used only used for city textbox.
venky n115 reputationPosted Mar 12, 2015, 1:54 AM EDT
$(document).ready(function () {
$("#ddcity").change(function () {
var city = $("#ddcity").val();
var geocoder = new google.maps.Geocoder();
var com = city;
geocoder.geocode({ 'address': com }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var x = results[0].geometry.location.lat();
var y = results[0].geometry.location.lng();
var latlng = new google.maps.LatLng(x, y);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map($("#map-canvas").val(), myOptions);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(x, y),
map: map,
title: com
});
var infowindow = new google.maps.InfoWindow({
content: com
});
infowindow.open(map, marker);
google.maps.event.addDomListener(window, 'load');
} else {
res.innerHTML = "Enter correct Details: " + status;
}
});
});
});
Lucky Laxman92 reputationPosted Mar 12, 2015, 2:39 AM EDT
You given that code is wrong some Js error .
i modified all please go n check i am given code its work fine Happy Coding .
Lucky Laxman92 reputationPosted Mar 12, 2015, 2:41 AM EDT
Please check the modified code ..
Thanks,
venky n115 reputationPosted Mar 12, 2015, 4:00 AM EDT
Another one doubt this coding used in inherited(master into master page) master page cant working.the javascript cant work on the inherited master page.plz tel me sir how to use this coding for master page...
the inherited master page only one contentplaceholder so not working.normal asp page successfully executed sir.plz help me sir.