juancoffee Posted August 10, 2014 Report Share Posted August 10, 2014 Hello All I want to restrict what geographic location users can submit my forms from. Basically, I want the form to look up the latitude and longitude and match it against ones on my table. Then (within a couple of hundred feet or so) I want it to either- Accept the location the user is at as being the one I've agreed and submit the data Don't accept the user's location (they are more than a couple of hundred feet away from the latitude and longitude on my table) and put up an error message 'Sorry - you are not in the right location to complete this form'. I know this can be done, but it is way above my technical ability I'm afraid. Any help from you wonderful useful people out there? Your hopefully Duncan Quote Link to comment Share on other sites More sharing options...
Jan Posted August 12, 2014 Report Share Posted August 12, 2014 Hello Duncan, There is the Generate Geolocation Coordinates from Form Submissions article. I hope, it can help. Quote Link to comment Share on other sites More sharing options...
juancoffee Posted August 12, 2014 Author Report Share Posted August 12, 2014 Hi Jan Thanks for this. Yes, I'd seen that article. The bit I can't do however is take that data and compare it against set data in my tables. With a little fiddling about, I can get the 'lat' and 'long' to compare against those that I have specified. I started to get really confused though when i tried to build some tolerance in. If the acceptable area is a reasonable size (a sports hall, or supermarket for example) then the specific latitude and longitude only will be too restrictive. That was when my brain (which is admittedly very small) started to melt down... Duncan Quote Link to comment Share on other sites More sharing options...
Jan Posted August 14, 2014 Report Share Posted August 14, 2014 Hi Duncan, It seems I have found a solution. I am not sure that it is the best way. A user enters his coordinates on a Reports DataPage. On Results page the tables is hidden, the Java Script checks whether message "No records found" is displayed. If yes, error message is displayed and the Search form is displayed again. Else a user is redirected to a Submission form, where he/she enters a data. Please try next steps: 1) Create a Reports DataPage, add the Distance Search By Coordinates on the Select Search Fields step. 2) On the next step, select the Distance field, select the Hidden in the Form element drop down box and enter your Default Value. 3) On the Configure Results Page Fields, add the following code to the Header: <div align="center"> <p>Processing...</p></div> 4) On the Configure Results Page Fields, add the following code to the Footer: <script type="text/javascript"> if(document.getElementById("caspioform")) { document.getElementById("caspioform").style.display = 'none'; var place_is_found = 1; var elems = document.getElementsByTagName("p"); for (var i=0, m=elems.length; i<m; i++) { if (elems[i].innerHTML== "No records found. Please, enter more short query.") { place_is_found = 0; } } if (place_is_found==1) { window.location = "http://www.caspio.com/"; } else { alert("Warning message"); window.history.back(); } } </script> Please enter the address of your DataPage instead of "http://www.caspio.com/". Also enter your message instead of "Warning message". I hope it helps. Quote Link to comment Share on other sites More sharing options...
juancoffee Posted August 15, 2014 Author Report Share Posted August 15, 2014 Hi Jan That's great - thanks very much for your help with this. I should be able to work out how to put it all together now. Thanks again - it is very much appreciated. Regards Duncan Quote Link to comment Share on other sites More sharing options...
Kurumi Posted August 12, 2022 Report Share Posted August 12, 2022 Hi! Just an update on this, Caspio has a new Tech tip called Auto-filling Forms with User Location. To know more on how to implement it in the DataPage, you can check it here: https://howto.caspio.com/tech-tips-and-articles/advanced-customizations/auto-fill-forms-with-user-location/ 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.