I am using the Formidable Pro Wordpress plugin and I am trying to figure how to achieve the following:
I need the users gps location in two form fields when a check box is clicked. I have two scripts and have no idea how to combine them.
First gets the location:
var x=document.getElementById(“demo”);
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.watchPosition(showPosition);
}
else{x.innerHTML=”Geolocation is not supported by this browser.”;}
}
function showPosition(position)
{
x.innerHTML=”Latitude: ” + position.coords.latitude +
“<br>Longitude: ” + position.coords.longitude;
}
Next is one that I was told to use to change the value of the fields:
jQuery(document).ready(function($){
$('input[name="item_meta[30]"]').change(function(){
$('select[name="item_meta[31]"], select[name="item_meta[32]"]').val('');
})
})
I tried this with no luck, as I have no idea what I am doing...
jQuery(document).ready(function($){
$('input[name="item_meta[29]"]').change(function(){
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(change);
}
else{x.innerHTML="Geolocation is not supported by this browser.";}
}{
$('input[name="item_meta[30]"]').val(position.coords.latitude);})
$('input[name="item_meta[31]"]').val(position.coords.longitude);})
})
Any help is much appreciated!