Forum: Ruby on Rails Events in view 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.
24c539689cd95ef54ed10234957d6fc1?d=identicon&s=25 Ike (Guest)
on 2007-07-07 22:58
(Received via mailing list)
I have taken an example wherein, using Ajax, the values of a second
combobox are populated by a change in the primary combobox. The code
is shown below.

I realise it will seem as though I am asking someone to write the code
for me, BUT, can someone please show me, by way of an example how to
amend my index.rhtml below to use, say a radio button group instead of
a combobox, wherein when you change the radio button group, the
secondary combobox is changed, without having to incorporate a submit

I somehow need someone to kickstart me here with this, and I can
bootstrap the rest of what I am trying to do. Thanks. R. Vince

#in mycontroller:

  def create_select
    indArr=["Nordic Skiing", "Inline Skating","Tennis",
      "Triathlon","Road Racing","Figure Skating",
      "Weight Lifting","Speed Skating","Snowboarding"];
    if params[:categories].index('Team') != nil
      render :partial => "options", :locals => { :sports =>
teamArr,:sptype => "team"}
    elsif params[:categories].index('Individual') != nil
      render :partial => "options", :locals => { :sports =>
indArr, :sptype => "individual" }
      str="<select id='individual' name='individual'>
      render :text => str;


   <%= form_remote_tag(:update => "sel_con",:url => {
      :action => :create_select },
      :position => "top",:success => "$('sel_con').innerHTML=''" ) %>
      Please select a sports category:
      <%= select_tag "categories",
      "<option>Team</option><option>Individual</option>" %>
    <div id="sel_con"></div>
      <%= submit_tag "Show Sports" %>
    <%= end_form_tag %>


   <select id="<%= sptype %>" name="<%= sptype %>">
   <% sports.each do |sport| %>
   <option><%= sport %></option>
   <% end %>
This topic is locked and can not be replied to.