Combo box value from another combo box

Hi, I would like to know how can I load the values of a second box
based on the id of the first combo
the first one is university and has id and name
the second one is course and it depends of the unviersity since each one
has its owns courses and prices (example…)

Use an observer to observe the change event of combo box 1 and send an
ajax request to the server and load the courses into combo box 2
(initially empty),

You can use the :with option with the observe_field method to pass the
value of combo 1 to the server

In your controller use a render :inline with
options_from_collection_for_select to generate the options for combo 2

Something along those line should do the trick.

-Ivan

On Mar 20, 12:24 am, Adriano L. [email protected]

There is also and plugin titled ‘related_select_forms’ which is pretty
cool
too. You could also use remote_function called from the select tag’s
onchange attribute to update a partial containing the other select box.

Raul

----- Original Message -----
From: “Ivan V” [email protected]
To: “Deploying Rails” [email protected]
Sent: Thursday, March 20, 2008 3:46 AM
Subject: [Rails-deploy] Re: Combo box value from another combo box

Use an observer to observe the change event of combo box 1 and send an
ajax request to the server and load the courses into combo box 2
(initially empty),

You can use the :with option with the observe_field method to pass the
value of combo 1 to the server

In your controller use a render :inline with
options_from_collection_for_select to generate the options for combo 2

Something along those line should do the trick.

-Ivan

On Mar 20, 12:24 am, Adriano L. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs