Forum: Ruby on Rails select_tag question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Af3cecc8af253b5acd3c09c5b67c0074?d=identicon&s=25 Valentino Lun (on9west)
on 2009-02-20 11:59
Dear all

I want to create two select_tag in view, the second select_tag will
depend on the first select_tag values.

i.e. If the first select_tag selected AHN, then the second have value
[CPS,HMS,MBS,BBS] for selection. If the first select_tag selected NDH,
only [ABS,CPS] is available in second select_tag. I have no idea how to
implement this. Please give me some advices. Thank you.

tables
column_1   column_2
AHN        CPS
AHN        HMS
AHN        MBS
AHN        BBS
NDH        ABS
NDH        CPS
PWH        CPS
PWH        MBS
PWH        CRS

enquiries controller
@column_1= Table.find(:all).collect {|x| [x.column_1, x.column_1]}.uniq

view/enquiries
<% form_tag do %>
  <%= select_tag(:column_1, options_for_select(@column_1)) %>
  <%= select_tag(:column_2, #How to do here?) %>
  <%= submit_tag "search" %>
<% end %>

Many thanks

Valentino
This topic is locked and can not be replied to.