I am using this function to save user filled data into my database.
The problem is that the variables defined within <script type="text/
javascript"> are not visible in  <% ...... %>(where database is being
connected to and insert query being run) :
<script type="text/javascript">
function saveData() {
      var title = escape(document.getElementById("title").value);
      var address = escape(document.getElementById("address").value);
      var lastvisiton = escape(document.getElementById
("lastvisiton").value);
      var author = escape(document.getElementById("author").value);
      var type = document.getElementById("type").value;
      var latlng = marker.getLatLng();
      var lat = latlng.lat();
      var lng = latlng.lng();
      <%
        Connection con=null;
        ResultSet rst=null;
        Statement stmt=null;
        try{
        String url="jdbc:mysql://localhost:3306/places";
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        con = DriverManager.getConnection(url, "root", "abhishek");
        stmt=con.createStatement();

        String sql = "INSERT INTO markers
(name,address,monthday,lat,lng,type,author)
values('"+title+"','"+addr+"','"+lastvisiton+"','"+lat+"','"+lng
+"','"+type+"','"+author+"')";
//problem is in the above line: variables
title,addr,lastvisiton,lat,lng,author,etc are not accessible here. How
to get them here ?

stmt.executeUpdate(sqls);
        rst.close();
        stmt.close();
        con.close();
        }catch(Exception e){
        System.out.println(e.getMessage());
        }
     %>
  marker.closeInfoWindow();
  document.getElementById("message").innerHTML = "Location added.";
}
</script>

I hope all of you can get my problem. How do i get the values in my <
%......%> section.
Thank you
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to