Mettre une valeur dans un champ <input>
Salut tout le monde J'espère que vous allez bien, c'est mon code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| <!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>trace your location</h1>
<button onClick="getLocation()">Get Location</button>
</div>
<div id="geo_output">
<script src="http://code.jquery.com/jquery-2.2.4.min.js"> </script>
<script>
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;
}
</script>
</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>
</form>
</body>
</html> |
quand je l'exécute, il m'a donné un bon résultat
mais je veux savoir comment je peux le faire, quand je clique sur gate location buton, la latitude et la longitude vont insérer directement et automatiquement sur le bon texte d'entrée
Code:
1 2 3
| <input type="text" name="lat" placeholder="latitude">
<br>
<input type="text" name="lon" placeholder="longitude"> |
Merci les amis