Hi all, I am looking for the simplest method to accomplish the following:- I have a RoR form for taking line items for an order. I have got autocomplete working for the Product Description so that users can find a product really easily. What I want though, is for whenever a user accepts a product description using the autocompleter, the product_code, product_units and product_price fields also get automatically populated from the selected record from the product masterfile. What is the best way to achieve this using RoR? Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2007-Apr-23  07:23 UTC
Re: Getting AutoComplete to populate other fields
CyberFerret a écrit :> I have a RoR form for taking line items for an order. I have got > autocomplete working for the Product Description so that users can > find a product really easily. What I want though, is for whenever a > user accepts a product description using the autocompleter, the > product_code, product_units and product_price fields also get > automatically populated from the selected record from the product > masterfile.Put these in your <li>''s as well, say in <span> elements with proper class names (you can then exclude them from auto-completion use by properly setting the auto-completer''s ''select'' option). Then use the afterUpdateElement callback to grab these ($$ or getElementsByClassName should do) and auto-populate your other fields. -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: 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 -~----------~----~----~----~------~----~------~--~---
Christophe,
Thanks for this information - I got it working great now.
I had some trouble getting the :select option to pick out the <span>
that I was after, but I soon worked out that the syntax for the
autocomplete was:-
<% text_field_with_auto_complete :model, :column, {}, :select =>
"myspan" %>
I didnt realise that you needed the empty braces ''{}'' after
the column
name to get the parameters in the right order.
Thanks again for your help - I appreciate it.
On Apr 23, 4:23 pm, Christophe Porteneuve
<t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org>
wrote:> CyberFerret a écrit :
>
> > I have a RoR form for taking line items for an order.  I have got
> > autocomplete working for the Product Description so that users can
> > find a product really easily.  What I want though, is for whenever a
> > user accepts a product description using the autocompleter, the
> > product_code, product_units and product_price fields also get
> > automatically populated from the selected record from the product
> > masterfile.
>
> Put these in your <li>''s as well, say in <span>
elements with proper
> class names (you can then exclude them from auto-completion use by
> properly setting the auto-completer''s ''select''
option).
>
> Then use the afterUpdateElement callback to grab these ($$ or
> getElementsByClassName should do) and auto-populate your other fields.
>
> --
> Christophe Porteneuve a.k.a. TDD
> "[They] did not know it was impossible, so they did it." --Mark
Twain
> Email: t...-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
-~----------~----~----~----~------~----~------~--~---