[LRUG] Geocoding and form submission

Andrew Stewart boss at airbladesoftware.com
Fri Apr 10 03:20:28 PDT 2009


Hi El Rug,

This isn't a Ruby question...sorry!  But I know many of you are good  
at JavaScript too.

I have an HTML form with a text field.  Bound to the field's blur  
event is a function that geocodes the field's value via Google and  
sets the returned latitude and longitude in hidden fields in the form.

This works perfectly when the user types a value into the field, then  
tabs/clicks out of the field, and then submits the form.  The problem  
is when the user types a value into the field and submits the form  
without leaving the field: the geocoding never has a chance to happen.

I thought I could solve this by attaching to the form's submit event a  
handler which does the geocoding and then submits the form.  The  
geocoding works but the form submits its fields' values as they were  
when the submit event fired -- so the new, geocoded values are ignored.

Is there a way to solve this?

Thanks and regards,

Andy Stewart

-------
http://airbladesoftware.com






More information about the Chat mailing list