You're going to run into a problem if Google can't geocode the IP
address, in which case google.loader.ClientLocation is set to null.
If that happens, your if statement may error out because there's
nothing past google.loader.ClientLocation. I would probably recommend
going with something like this:
if
(google
.loader
.ClientLocation
&&google
.loader
.ClientLocation
.address&&typeof(google.loader.ClientLocation.address.city)!=null)){
Other than that, it looks like you have a pretty firm grasp on what
needs to happen. Did you have a specific question?
Jeremy R. Geerdes
Effective website design & development
Des Moines, IA
For more information or a project quote:
http://jgeerdes.home.mchsi.com
http://jgeerdes.blogspot.com
http://jgeerdes.wordpress.com
[email protected]
Unless otherwise noted, any price quotes contained within this
communication are given in US dollars.
If you're in the Des Moines, IA, area, check out Debra Heights
Wesleyan Church!
And check out my blog, Adventures in Web Development, at
http://jgeerdes.blogspot.com
!
On Jul 31, 2009, at 2:36 PM, Genpowerusa wrote:
>
> hi all I would like to implement the location javascript snippet into
> a hidden field in a form so that when a user enters their email
> address we can see what area they are contacting us from :
>
> Here's the snippet that uses the API
>
> <script type="text/javascript" src="http://www.google.com/jsapi"> </
> script>
> <script type="text/javascript">
> if (typeof(google.loader.ClientLocation.address.city) != null) {
> document.write(google.loader.ClientLocation.address.city
> +", "
> +google.loader.ClientLocation.address.region);
> } else {
> document.write("Unknown location")
> }
> </script>
>
> And I would like to add it to a simple form field like this:
>
> <input type="hidden" name="Location" value="{user location here}">
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google AJAX APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---