- Posts: 10
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
<button class="gpsLink" type="button">Get GPS Data</button> <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var q1ID = '{QID}'; var q1 = $('#question'+q1ID); // Click event for the button $('.gpsLink').click(function(){ getGPS(); }); function getGPS() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showGPS, gpsError); } else { $('input.text', q1).val('No GPS Functionality'); } } function gpsError(error) { alert('GPS Error: '+error.code+', '+error.message); } function showGPS(position) { $('input.text', q1).val(position.coords.latitude+', '+position.coords.longitude); } }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var q1ID = '{QID}'; var q1 = $('#question'+q1ID); function getGPS() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showGPS, gpsError); } else { $('input.text', q1).val('No GPS Functionality'); } } function gpsError(error) { alert('GPS Error: '+error.code+', '+error.message); } function showGPS(position) { $('input.text', q1).val(position.coords.latitude+', '+position.coords.longitude); } getGPS(); }); </script>