I see. In that case, I would use something like this in your second  
script (i.e., not the jsapi one):

function popHiddenField(){
  if(!google.loader||!google.loader.ClientLocation||! 
google.loader.ClientLocation.address||! 
google.loader.ClientLocation.address.city){
   return;
  }
  var addy = google.loader.ClientLocation.address
  document.getElementById('id_of_hidden_input').value = addy.city+',  
'+addy.region;
}
google.setOnLoadCallback(popHiddenField);


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:54 PM, Genpowerusa wrote:

>
>
>
> On Jul 31, 3:49 pm, Jeremy Geerdes <[email protected]> wrote:
>> 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.comhttp 
>> ://jgeerdes.blogspot.comhttp://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, 
>> athttp://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}">
>
>
> Thanks Jeremy, actually my question is in what form can I add this to
> the hidden field. Do I make it into a variable, call it from a .js
> file, etc.. I'm unsure about this -thanks.
> >


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to