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