I need to have longitude and latitude inside the input form, but I cannot figure out how to do it, I have tried a few examples, as seen in the below code (doesnt work).
<script>
function data(){
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
}
}
function showPosition(position) {
x.innerHTML =
"Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
}</script>
<form name="test_form">
<input id="demo" type="text" value="">
</form>
<button onclick="getLocation();">GO</button>
Expected results: Longitude and Latitude to be inside the input box, or if possible, longitude in one input box, latitude in anoter