Hello, i must save latitude and longitude data on db.
I obtain the data from the script, but i'm not able to save data on db.
Anyone can help me?
Thanks
I obtain the data from the script, but i'm not able to save data on db.
<!DOCTYPE html>
<html>
<body>
<body onload="getLocation()">
<p id="demo"></p>
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
document.getElementsByName('lat')[0].value = position.coords.latitude;
document.getElementsByName('lng')[0].value = position.coords.longtitude;
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude +
"<br>Precisione: " + position.coords.accuracy;
}
</script>
</body>
</html>
Anyone can help me?
Thanks
if you are able to set the value of 2 hidden form fields to lat and lang then save the form then it should be stored.
you can check if the fields are set using the browser's console
you can check if the fields are set using the browser's console
You need to login to be able to post a reply.
