CARADVERT2013 Posted November 27, 2013 Report Share Posted November 27, 2013 Hi Support team I created a table and this table records will be created by user when the run a Form. In this form, I try records user GEO location. I attached a HTML Block into the form. Please see the code : Once user to execute this form and click submit, user GEO location will be updated into the table by field Latitude and Longitude. I have tried so many time, but stiff not successful to update this two field. Can you please help to check what is the missing, please? Regards Patrick Li ------------------------------------------------- </div> <script> if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(GEOprocess, GEOdeclined); } else{ document.getElementById('geo').innerHTML = 'Your browser do not support geo-location.'; } // called when the browser has shown support of navigator.geolocation function GEOprocess(position) { gLongitude = position.coords.longitude; gLatitude = position.coords.latitude; console.log('latitude: ' + gLatitude + ' ; longititude: ' + gLongitude); // update the page to show we have the lat and long //document.getElementById('geo').innerHTML = 'Latitude: ' + position.coords.latitude + ' Longitude: ' + position.coords.longitude; document.write(document.getElementbyId('geo')(position.coords.latitude([@field:Latitude]))) </script> ---------------------------------------------------------------------------------------- Hermantak 1 Quote Link to comment Share on other sites More sharing options...
ShWolf Posted December 5, 2013 Report Share Posted December 5, 2013 Hello Patrick, So you need to get user's geo position and put it to the hidden field on the form? Insert this code in to the footer of your DataPage (it's better to past JS code in to the Footer, when you work with data on the form, because content of the HTML block can be loaded before the form was fully loaded): <script type='text/javascript'> if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(GEOprocess, GEOdeclined); } else{ document.getElementById('InsertRecordGEO').value = 'Your browser do not support geo-location.'; } // called when the browser has shown support of navigator.geolocation function GEOprocess(position) { gLongitude = position.coords.longitude; gLatitude = position.coords.latitude; console.log('latitude: ' + gLatitude + ' ; longititude: ' + gLongitude); // update the page to show we have the lat and long document.getElementById('InsertRecordGEO').value = 'Latitude: ' + position.coords.latitude + ' Longitude: ' + position.coords.longitude; } function GEOdeclined() { document.getElementById('InsertRecordGEO').value = 'Your browser do not support geo-location.'; } </script> And replace GEO with your field's name. P.S. Field names will be different on the different form types. As example, on the Submission form you should use InsertRecordYOURFIELDNAME, on the Update form it will be EditRecordYOURFIELDNAME. Let me know if this helps. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.