if (navigator.geolocation) { var geolocation = {}; geolocation.latitude = 0; geolocation.longitude = 0; navigator.geolocation.getCurrentPosition(function (p) { geolocation.latitude = p.coords.latitude; geolocation.longitude = p.coords.longitude; }, function (error) { alert("Failed to get GPS location"); }); } else { alert("Failed to get GPS working"); } function loc() { document.getElementById("longitude").value = geolocation.latitude; document.getElementById("latitude").value = geolocation.longitude; }
<form name="photo" method="post" action="url"> <label for="name">Name:</label> <input type="text" name="name" id="Text1" value="" /> <label for="longitude">Longitude:</label> <input type="text" name="longitude" id="longitude" /> <label for="latitude">Latitude:</label> <input type="text" name="latitude" id="latitude" /> <label for="image">Image:</label> <input type="text" name="image" id="image" /> <input type="submit" value="Submit" /> </form>
function loc() { --- }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)