hi everybody I hope you are well,
here is my code:
var x = document.getElementById('geo_output');
//x.innerHTML = "here is geo_output";
function getLocation()
{
if(navigator.geolocation)
{
//x.innerHTML = "Supporting";
navigator.geolocation.getCurrentPosition(showPosition);
}
else
{
x.innerHTML = "Browser not Supporting";
}
}
function showPosition(position)
{
x.innerHTML = "latitude = "+position.coords.latitude;
x.innerHTML += "<br />"
x.innerHTML += "longitude = "+position.coords.longitude;
}
$('#geo_output').click(getLocation)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h1>trace your location</h1>
<button onClick="getLocation()">Get Location</button>
<div id="geo_output">
</div>
<br> <br> <br> <br> <br>
<div id="form_output">
<form action="includes/signup.php" method="POST">
<input type="text" name="lat" placeholder="latitude">
<br>
<input type="text" name="lon" placeholder="longitude">
<br>
<input type="text" name="id" placeholder="id">
<br>
<input type="text" name="name" placeholder="first_name">
<br>
<input type="text" name="address" placeholder="address">
<br>
<input type="text" name="description" placeholder="description">
<br>
<button type="submit" name="submit"> envoyer </button>
</div>
when i execute it , it gives me a correct result.
but i want to know how to do that, when i click on the button gate location, the latitude and longitude will be inserted directly and automatically into their <input>
<input type="text" name="lat" placeholder="latitude">
<br>
<input type="text" name="lon" placeholder="longitude">
thank you friends