I'm trying to make info windows pop up upon placing a marker and then having the user fill in some information on a form in the info window. When the user submits the form it saves it to a mysql table. The problem is with my saveData() function.
<script type="text/javascript"> //<![CDATA[ var customIcons = { dui: { icon: 'http://labs.google.com/ridefinder/images/mm_20_black.png', shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png' }, trap: { icon: 'http://labs.google.com/ridefinder/images/mm_20_white.png', shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png' }, redlight: { icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png', shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png' } }; var map = null; function load() { map = new google.maps.Map(document.getElementById("map"), { center: new google.maps.LatLng(37.441063,-122.146683), zoom: 13, mapTypeId: 'roadmap' }); google.maps.event.addListener(map, 'click', function(event) { placeMarker(event.latLng); }); var infoWindow = new google.maps.InfoWindow; var linkfile = <?php echo "\"genxml.php?p=".$_GET['p']."\"" ?>; downloadUrl(linkfile, function(data) { var xml = data.responseXML; var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var name = markers[i].getAttribute("name"); var address = markers[i].getAttribute("address"); var type = markers[i].getAttribute("type"); var point = new google.maps.LatLng( parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var popuphtml = "<div class=\"popup\"><b>" + name + "</b> <br/>" + address +"</div>"; var icon = customIcons[type] || {}; var marker = new google.maps.Marker({ map: map, position: point, icon: icon.icon, shadow: icon.shadow }); bindInfoWindow(marker, map, infoWindow, popuphtml); } }); } function saveData(location) { var name = escape(document.getElementById("name").value); var address = document.getElementById("address").value; var type = document.getElementById("type").value; location = new google.maps.marker.getLatLng(); var lat = latlng.lat(); var lng = latlng.lng(); var url = "addrow.php?name=" + name + "&address=" + address + "&type=" + type + "&lat=" + lat + "&lng=" + lng; downloadUrl(url, function(data, responseCode) { if (responseCode == 200 && data.length <= 1) { marker.InfoWindow.close(); document.getElementById("message").innerHTML = "Location added."; } }); } function placeMarker(location) { var newmarkerhtml = "<div class=\"popup\">" + "Name: <input type='text' id='name'/><br>" + "Last Seen: <select id='address'>" + "<option value='now' SELECTED>Now</option>" + "<option value='15m'>< 15mins</option>" + "<option value='30m'>30mins</option>" + "<option value='1h'>1 Hour +</option></select><br>" + "Type: <select id='type'>" + "<option value='trap' SELECTED>Speed Trap</option>" + "<option value='dui'>DUI Checkpoint</option>" + "<option value='redlight'>Red Light Cam</option>" + "</select><br>" + "<input type='button' value='Report' onclick='saveData(clickedLocation)'/></div>"; var infoWindow = new google.maps.InfoWindow; var clickedLocation = new google.maps.LatLng(location); var newmarker = new google.maps.Marker({ position: location, map: map, icon: 'http://labs.google.com/ridefinder/images/mm_20_purple.png', shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png', draggable: true }); bindInfoWindow(newmarker, map, infoWindow, newmarkerhtml); } function bindInfoWindow(marker, map, infoWindow, html) { google.maps.event.addListener(marker, 'click', function() { infoWindow.setContent(html); infoWindow.open(map, marker); }); } function downloadUrl(url, callback) { var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest; request.onreadystatechange = function() { if (request.readyState == 4) { request.onreadystatechange = doNothing; callback(request, request.status); } }; request.open('GET', url, true); request.send(null); } function doNothing() {} </script> -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to google-maps-js-api...@googlegroups.com. To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.