TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
venky n
NA
110
38.3k
how to pass value dropdown using javascript
Mar 11 2015 7:50 AM
i am create google map using javascript.1st coding am using textbox to pass latitude and longitude value ,map is show correct way.
But ,that some work in 2coding . am modify to drop down control to pass latitude and longitude value .not working.
please help me..
1.Text box coding:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Show Google Map with Latitude and Longitude in asp.net website</title>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=false">
</script>
<script language="javascript" type="text/javascript">
function initialize() {
var selectQueryString = "SELECT * FROM Product ORDER BY Name";
var lat = document.getElementById('txtlat').value;
var lon = document.getElementById('txtlon').value;
var myLatlng = new google.maps.LatLng(lat, lon) // This is used to center the map to show our markers
var mapOptions = {
center: myLatlng,
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP,
marker: true
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng
});
marker.setMap(map);
}
</script>
</head>
<body >
<form id="form1" runat="server">
<table>
<tr>
<td>Enter Latitude:</td>
<td><input type="text" id="txtlat" value="13.053147716796578" /> </td>
</tr>
<tr>
<td>Enter Longitude:</td>
<td><input type="text" id="txtlon" value="80.2501953125" /> </td>
</tr>
<tr>
<td></td>
<td><input type="button" value="Submit" onclick="javascript:initialize()" /> </td>
</tr><tr>
</tr>
</table>
<div id="map_canvas" style="width: 500px; height: 400px"></div>
</form>
</body>
</html>
working this code.
2.dropdown coding:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Show Google Map with Latitude and Longitude in asp.net website</title>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=false">
</script>
<script language="javascript" type="text/javascript">
function listBoxSelectedIndexChanged() {
var ddcID = '<%= ddcity.ClientID %>'
if (document.getElementById(ddcID).selectedIndex >= 0)
{
var selectQueryString = "SELECT lat_val,lon_val FROM TBLmap where t_description='abu'";
//var lat = document.getElementById('txtlat').value;
//var lon = document.getElementById('txtlon').value;
var myLatlng = new google.maps.LatLng(selectQueryString) // This is used to center the map to show our markers
var mapOptions = {
center: myLatlng,
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP,
marker: true
}
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng
});
marker.setMap(map);
}
</script>
<body >
<form id="form1" runat="server">
<table>
<tr>
<asp:DropDownList ID="ddcity" AutoPostBack="true" onchange="listBoxSelectedIndexChanged()" runat="server">
</asp:DropDownList>
</tr>
</table>
<div id="map_canvas" style="width: 500px; height: 400px"></div>
</form>
</body>
</html>
this code not working..
Reply
Answers (
1
)
how to close current webform after click messagebox ok butto
Class and Objects