Hi, I''d like to implement in my project dynamic dropdown lists. Example: user will select one option from the parent dropdown list, lets say it''ll be COUNTRY and in the child dropdown will be generated all CITIES tied with this selected country. I could then have relevant info in my form. Country and one of its city. I know, this is not much abour RoR, however it has something to do w/ Ajax. I really like autocomplete feature in RoR and I''m sure this dynamic dropdowns should be done easy in Ajax too. any clues..? thanks and have a great day -> keli (milos kelemen)
milos kelemen wrote:>> I''d like to implement in my project dynamic dropdown lists. > Example: > user will select one option from the parent dropdown list, lets say > it''ll be COUNTRY and in the child dropdown will be generated all CITIES > tied with this selected country.You could use an observe_field to monitor the choice in the first select box, as in this example: http://www.roryhansen.ca/?p=9 This is something I''m currently experimenting with myself - will let you know how it goes. -- Posted via http://www.ruby-forum.com/.
Nick Ce wrote:> milos kelemen wrote:> > >>I''d like to implement in my project dynamic dropdown lists. >>Example: >>user will select one option from the parent dropdown list, lets say >>it''ll be COUNTRY and in the child dropdown will be generated all CITIES >>tied with this selected country. > > > You could use an observe_field to monitor the choice in the first select > box, as in this example: > http://www.roryhansen.ca/?p=9 > > This is something I''m currently experimenting with myself - will let you > know how it goes. >tnak you nick, I''ll let you know how it goes, -> keli
Nick Ce wrote:> milos kelemen wrote:> > >>I''d like to implement in my project dynamic dropdown lists. >>Example: >>user will select one option from the parent dropdown list, lets say >>it''ll be COUNTRY and in the child dropdown will be generated all CITIES >>tied with this selected country. > > > You could use an observe_field to monitor the choice in the first select > box, as in this example: > http://www.roryhansen.ca/?p=9 > > This is something I''m currently experimenting with myself - will let you > know how it goes. >Nick, thanks for your help again... this script works as it should
hi, someone asked the exact same question here ..see this http://article.gmane.org/gmane.comp.lang.ruby.rails/32790/matchand this http://article.gmane.org/gmane.comp.lang.ruby.rails/33824/matchVivek On 12/12/05, milos kelemen <kelemen-3bu9hXS+wrdaa/9Udqfwiw@public.gmane.org> wrote:> > Nick Ce wrote: > > milos kelemen wrote:> > > > >>I''d like to implement in my project dynamic dropdown lists. > >>Example: > >>user will select one option from the parent dropdown list, lets say > >>it''ll be COUNTRY and in the child dropdown will be generated all CITIES > >>tied with this selected country. > > > > > > You could use an observe_field to monitor the choice in the first select > > box, as in this example: > > http://www.roryhansen.ca/?p=9 > > > > This is something I''m currently experimenting with myself - will let you > > know how it goes. > > > Nick, > > > thanks for your help again... > > this script works as it should > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
milos kelemen wrote:> Nick, > > thanks for your help again... > > this script works as it shouldNo problem - glad yours works ok - still having problems with mine :( I decided to go down the partials route as used in the posts that Vivek linked to, here http://article.gmane.org/gmane.comp.lang.ruby.rails/33824/match= and here http://article.gmane.org/gmane.comp.lang.ruby.rails/33824/match At present I have this: http://www.rafb.net/paste/results/YxkO1V47.html Unfortunately, when I make a choice on the first select, no content appears within the person_list div - can anyone see anything wrong at all? -- Posted via http://www.ruby-forum.com/.
Are you using Firefox? If so, make sure that the ID of the select box is actually job_company_id. I''m not familiar with the output of collection_select, but it may output only the NAME attribute and not the ID unless you explicitly tell it to. On 12/12/05, Nick C. <graphis1-ee4meeAH724@public.gmane.org> wrote:> > milos kelemen wrote: > > Nick, > > > > thanks for your help again... > > > > this script works as it should > > No problem - glad yours works ok - still having problems with mine :( > I decided to go down the partials route as used in the posts that Vivek > linked to, here > http://article.gmane.org/gmane.comp.lang.ruby.rails/33824/match= and > here http://article.gmane.org/gmane.comp.lang.ruby.rails/33824/match> > At present I have this: http://www.rafb.net/paste/results/YxkO1V47.html > > Unfortunately, when I make a choice on the first select, no content > appears within the person_list div - can anyone see anything wrong at > all? > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
In the post which I linked to..I didnt understand the use of :object ..I know of :collection which calls the template repeatedly..whats with this :object ? does anyone here have an idea? I saw rory''s solution.. easier to follow..Thanks for the tip. Vivek On 12/13/05, Rory Hansen <roryhansen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Are you using Firefox? If so, make sure that the ID of the select box is > actually job_company_id. I''m not familiar with the output of > collection_select, but it may output only the NAME attribute and not the ID > unless you explicitly tell it to. >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Rory Hansen wrote:> Are you using Firefox? If so, make sure that the ID of the select box is > actually job_company_id. I''m not familiar with the output of > collection_select, but it may output only the NAME attribute and not the > ID unless you explicitly tell it to.Thanks for the reply Rory. I''m actually using Camino, and the collection_select generates this: <p><label for="job_company_id">Client</label><br/> <select id="job_company_id" name="job[company_id]"> <option value="1">company A</option> <option value="2">company B</option> which looks ok to me. Vivek wrote:> In the post which I linked to..I didnt understand the use of :object ..I > know of :collection which calls the template repeatedly..whats with this > :object ? does anyone here have an idea?>From the Agile Rails book: "The :object parameter identifies an objectto be passed into the partial. This object will be available within the template via a local variable with the same name as the template." Not sure I understand this fully - does my error lie with the naming of the object variable perhaps? Still can''t get it to work as expected. The DIV I''m trying to update is nested within a form; will that make any difference? http://www.rafb.net/paste/results/YxkO1V47.html -- Posted via http://www.ruby-forum.com/.
Nick C wrote:> http://www.rafb.net/paste/results/YxkO1V47.htmlSolved it - it was a syntax error - one measly single quote missing from :with => "''job_company_id=''+value" The partial method in conjunction with collection_select certainly seems a tidy way of doing dynamic drop downs. Thanks to all those who chipped in. -- Posted via http://www.ruby-forum.com/.