Hi I''d like to use the Autocomplete script but have the following problem: my mysql db with 3 fields: city | longitude | latitude my website with 3 textinputs: city: lon: lat: Autocomplete enabled in city field. I would like to select an entry from the autocomplete list but also have the longitude and latitude written into the other two fields. Is this possible and how would I do it? Any help much appreciated. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey, hagonk a écrit :> Autocomplete enabled in city field. I would like to select an entry > from the autocomplete list but also have the longitude and latitude > written into the other two fields.Return the other two values within the city''s <li>, using CSS class "informal" to avoid putting them in the auto-completed city field (and possibly more classes to style them differently or actually hide them), then use the afterUpdateElement callback to grab the <li> and explore its DOM to extract your two other pieces of data, which you can then put in the other two input fields. What I don''t understand in the first place is WHY, if the DB already HAS the coordinates, you would want your user to type them in... -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 6, 2007, at 1:42 PM, hagonk wrote:> > Hi > I''d like to use the Autocomplete script but have the following > problem: > > my mysql db with 3 fields: > city | longitude | latitude > > my website with 3 textinputs: > city: > lon: > lat: > > Autocomplete enabled in city field. I would like to select an entry > from the autocomplete list but also have the longitude and latitude > written into the other two fields. > Is this possible and how would I do it?There are several solutions. I think the most simple is to pass them in some attribute of the LIs and process that on the client via the afterUpdateElement callback. If you are working with Rails you may use the plugin model_auto_completer to send the ID back to the server via its own callback :after_update_element, and have the page updated with RJS. I wrote that plugin but I''d mention it if I didn''t anyway. -- fxn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---