Forum: Ruby on Rails select_tag question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Valentino L. (Guest)
on 2009-02-20 12: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.

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

<% 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

This topic is locked and can not be replied to.