# Dynamic selects

**URL:** <https://www.ruby-forum.com/t/dynamic-selects/125673>\
**Category:** Rails\
**Created:** [January 11, 2008, 2:59am UTC](https://www.ruby-forum.com/t/dynamic-selects/125673 "2008-01-11T02:59:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nuby2ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@nuby2ruby](https://www.ruby-forum.com/u/nuby2ruby)\
**Post date:** [January 11, 2008, 2:59am UTC](https://www.ruby-forum.com/t/dynamic-selects/125673/1 "2008-01-11T02:59:31Z")

</div>

I have been doing some searching and looking on the forum for old topics  
on the best way to change a select box based on another. So far, I have  
only been able to get one way to work, and it only works in FireFox  
(does nothing in I.E.)

I’m having a bit of trouble relating a lot of the examples out there  
into what I am trying to do. Do I use the observe\_field, or  
onchange="\<%= remote\_function…  
There are just too many ways. I was told about jQuery having a change  
method that you pass a function to, but I failed to get that working as  
well.

My issue is that I have 4 list boxes. You choose from the first one and  
it populates the next two, then you select from the 3rd one and it  
populates the last one. I have 4 objects; MachineType, Machine, Issue,  
SubIssue.  
The MachineType has\_many :machines and :issues. The Issue has\_many  
:sub\_issues.  
I placed each select box into it’s own div whose id’s are the same as  
the model names.

 etc..

Is it better to use the options\_from\_collection\_for\_select helper, and  
just type out the select tags, or should I use the select helper such as  
f.select(:name)? Can anyone give me a good clear example on exactly how  
to do this?

Thanks,

~Jeremy

here are a few of the links I checked out that didn’t help me out.  
[http://www.roryhansen.ca/?p=9](http://www.roryhansen.ca/?p=9)  
[http://www.bobbyvandersluis.com/articles/unobtrusivedynamicselect.php#a](http://www.bobbyvandersluis.com/articles/unobtrusivedynamicselect.php#a)  
[http://lists.rubyonrails.org/pipermail/rails/2006-January/009728.html](http://lists.rubyonrails.org/pipermail/rails/2006-January/009728.html)  
[http://www.adamhegedus.com/2006/01/19/ajaxed-select-boxes-in-rails/](http://www.adamhegedus.com/2006/01/19/ajaxed-select-boxes-in-rails/)
