Hello, I have a form where the user can enter an address. Based on the user entering the zip code, I would like to use ajax to pull the city, state and county from the application database. observe_field doesn''t look quite right as it updates a dom element, not the fields themselves. I would appreciate any advice on rolling this functinality myself. Thanks, Dan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Tim Harding
2006-Sep-23 13:17 UTC
Re: updating fields based on another field value using ajax
Hi Dan, I think you can try to use the callback functionality to do this. http://rubyonrails.org/api/classes/ActionView/Helpers/PrototypeHelper.html#M000422 the observe_field doc says you can use any of the options from link_to_remote so if you can use the callbacks then you can have those perform javascript actions to set the field.value for the other form fields. here is the documentation on the callbacks: http://rubyonrails.org/api/classes/ActionView/Helpers/PrototypeHelper.html#M000412 the ajax call you make can return those values to you in a JSON string or something, i guess. hope that gets you somewhere. -Tim Dan Munk wrote:> Hello, > > I have a form where the user can enter an address. Based on the user > entering the zip code, I would like to use ajax to pull the city, state > and county from the application database. observe_field doesn''t look > quite right as it updates a dom element, not the fields themselves. > > I would appreciate any advice on rolling this functinality myself. > > Thanks, > Dan--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---