I have the following code:
<script type = "text/javascript">
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(geofields);
}
}
function geofields() {
if (document.getElementById('starthere').checked == 1) {
document.getElementById('start').value = position.coords.latitude + " " + position.coords.longitude;
} else {
document.getElementById('start').value = '';
}
}
</script>
I want function geofields(){ to display the GeoLocation, changing the value of ‘start’ element to the coordinates (received from the GetLocation() script), but it is not working with the code above. Any suggestions?
You need to add a
positionparameter togeofieldsand invokegetLocation(or set it as a handler).