You cannot combine Python and Javascript. The Python code is executed on the server *before* the HTML page is returned to the browser, and the Javascript is executed later in the browser. If you need to put something in the session from Javascript, you would have to pass the relevant data to web2py via an Ajax call and have the called function write the data to the session.
Anthony On Saturday, February 20, 2016 at 11:40:50 AM UTC-5, Rgb Aston wrote: > > <script type="text/javascript" src="http://www.google.com/jsapi?key= > <YOUR_GOOGLE_API_KEY>"></script> > <script type="text/javascript"> > if(google.loader.ClientLocation) > { > visitor_lat = google.loader.ClientLocation.latitude; > visitor_lon = google.loader.ClientLocation.longitude; > visitor_city = google.loader.ClientLocation.address.city; > visitor_region = google.loader.ClientLocation.address.region; > visitor_country = google.loader.ClientLocation.address.country; > visitor_countrycode = > google.loader.ClientLocation.address.country_code; > document.getElementById('yourinfo').innerHTML = '<p>Lat/Lon: ' > + visitor_lat + ' / ' + visitor_lon + '</p><p>Location: ' + visitor_city + > ', ' + visitor_region + ', ' + visitor_country + ' (' + visitor_countrycode > + ')</p>'; > {{session.lat=visitor_lat}} > {{session.lon=visitor_lon }} > } > else > { > document.getElementById('yourinfo').innerHTML = > '<p>Whoops!</p>'; > } > </script> > > > error: > > <type 'exceptions.NameError'> name 'visitor_lat' is not defined > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

