Hi !
How to get the lat/long of a user and embed it in a hiden field of a form ???
- include a javascript in a custom code inside your page.
This one I figured :
<script>
document.addEventListener('DOMContentLoaded', function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
const lat = position.coords.latitude;
const lon = position.coords.longitude;
// Set the latitude and longitude to hidden fields
document.getElementById('hiddenLatField').value = lat;
document.getElementById('hiddenLonField').value = lon;
}, function(error) {
console.error('Error obtaining location:', error);
});
} else {
console.error('Geolocation is not supported by this browser.');
}
});
</script>
- But then… how to pass thoses two data (lat/long) into a hidden form in Softr ??? (I use a button to open a modal with a form)