Untitled
3 years ago in Plain Text
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
Latitude: <input type="text" name="Latitude" id="lat"/> <br />
Longitude: <input type="text" name="Longitude" id="long">
</form>
<button onclick="getLocation()">Get Location</button><input type="submit" value="Submit" />
<script>
var x=document.getElementById("demo");
var y=document.getElementById("demo2");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
function showPosition(position)
{document.getElementById("lat").value = ""+ position.coords.latitude;
document.getElementById("long").value = ""+ position.coords.longitude;
}
</script>
</body>
</html>