# Combo box value from another combo box

**URL:** <https://www.ruby-forum.com/t/combo-box-value-from-another-combo-box/132371>\
**Category:** Deployment\
**Created:** [March 19, 2008, 2:24pm UTC](https://www.ruby-forum.com/t/combo-box-value-from-another-combo-box/132371 "2008-03-19T14:24:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrianod](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c2a13f/32.png) [@adrianod](https://www.ruby-forum.com/u/adrianod)\
**Post date:** [March 19, 2008, 2:24pm UTC](https://www.ruby-forum.com/t/combo-box-value-from-another-combo-box/132371/1 "2008-03-19T14:24:03Z")

</div>

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…)

---

<div class="post-metadata">

**Author:** ![adrianod](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c2a13f/32.png) [@adrianod](https://www.ruby-forum.com/u/adrianod)\
**Post date:** [March 20, 2008, 11:47am UTC](https://www.ruby-forum.com/t/combo-box-value-from-another-combo-box/132371/2 "2008-03-20T11:47:45Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![adrianod](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c2a13f/32.png) [@adrianod](https://www.ruby-forum.com/u/adrianod)\
**Post date:** [March 20, 2008, 4:55pm UTC](https://www.ruby-forum.com/t/combo-box-value-from-another-combo-box/132371/3 "2008-03-20T16:55:34Z")

</div>

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” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: “Deploying Rails” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
