Im trying to use the address from a form input that is in the POST and insert that adress into this javascript for geocoding it into a pin point on the map. I put the POST into a javscript variable but i cant seem to get that into the function that geodoces it. here is it live on a test site http://nickshanekearney.com/geo/
<?php $address = $_POST["address"]; ?>
<script>
var address = "<?php echo $_POST["address"]; ?>";
var geocoder;
var map;
function codeAddress() {
var address = document.getElementById("address").value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
</script>
<div id="map"></div>
"
) herevar address = "<?php echo $_POST["address"]; ?>";
. It's an error writing – Oki Erie Rinaldi 2 days agovar address = "<?php echo $_POST['address']; ?>";
– Oki Erie Rinaldi 2 days ago