HI
Can someone please help me, I am NOT proficient in Javascript at all.
Objective:
I have created a web-app that will run on users phones.
The app has multiple forms
I need to consistently get the users location (long/lat) no matter what form in the app they are in.
I have found some Javascript code that I believe will do what I want (see below)
BUT
I have no idea where to place this scripts
I have no idea how to get the long and alt from the Javscript into x2 variables so that I can POST these to my server.
Javascript I found:
[SIZE=16px]<script>[/SIZE]
[SIZE=16px]var x = document.getElementById(“demo”);
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.watchPosition(showPosition);
} else {
x.innerHTML = “Geolocation is not supported by this browser.”;
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}[/SIZE]
[SIZE=16px]</script>[/SIZE]