
This is my sample html page which contains inline javascript which calculates the geocode and tries to return the lattitude and longitude .But my question is how to submit all the form values with lattitude and longitude returned from showlocation funtion to submitform.jsp page and display latitude value in jsp page .
Index.html
<html>
<head>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA5yM-fP6TPUheIXxW3TxpVRRgJAR_YXLeqIBw9Qs7Dzlh-4wFexRUVFiN8RbSageQjhAggT3jom"
type="text/javascript"></script>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
geocoder = new GClientGeocoder();
function showlocation() {
var clientaddress = document.getElementById('addstreetname').value;
geocoder.getLocations(clientaddress, function(response) {
if (!response || response.Status.code != 200) {
alert("Sorry, we were unable to geocode the first address");
}
else {
var lat1 = response.Placemark[0].Point.coordinates[1];
var lng1 = response.Placemark[0].Point.coordinates[0];
return {latitude: lat1, longitude: lng1};
}
});
</script>
</head>
<body>
<form id="addresslistingform" action="submitform.jsp" onsubmit="returnshowlocation();">
Company_Name:<br/>
<input size="30" type="text" id="businessname" name="businessname"/><br/>
Zipcode:<br/>
<input size="30" type="text" id="zipcode" name="zipcode1"/><br/>
Street No:<br/>
<input size="30" type="text" id="addstreetno" name="streetno"/><br/>
Street Name:<br/>
<input size="30" type="text" id="addstreetname" name="streetname"/><br/>
State:<br/>
<select name="select2" id="select2" class="required" name="state" >
<option value="">Select Your State</option>
<option value="1"> karnataka</option>
<option value="2"> Kerala</option>
<option value="3"> Andhra Pradesh</option>
</select>
</form>
</body>
</html>
submitform.jsp
<%@ page language="java" import="java.sql.*" %>
<%
String driver = "com.mysql.jdbc.Driver";
Class.forName(driver).newInstance();
Connection con=null;
ResultSet rst=null;
Statement stmt=null;
try{
String url = "jdbc:mysql://localhost:3306/";
String dbName = "db";
String driverName = "com.mysql.jdbc.Driver";
String userName = "";
String password = "";
con = DriverManager.getConnection(url+dbName, userName, password);
stmt=con.createStatement();
}catch(Exception e){
System.out.println(e.getMessage());
}
String Company_Name=request.getParameter("businessname");
String Zipcode =request.getParameter("zipcode1");
String Street_Number=request.getParameter("streetno");
String Street_Name=request.getParameter("streetname");
String State= request.getParameter("state");
String Latitude=request.getParameter("Latitude");
out.println("latitude is :"+request.getParameter("Latitude"));
%>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.