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
button?
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"];
teamArr=["Soccer","Basketball","Football","Hockey",
"Baseball","Lacrosse"];
str="";
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" }
else
str="<select id=''individual''
name=''individual''>
<option>unknown</option></select>";
render :text => str;
end
end
#index.rhtml:
<%= form_remote_tag(:update => "sel_con",:url => {
:action => :create_select },
:position => "top",:success =>
"$(''sel_con'').innerHTML=''''" )
%>
<p>
Please select a sports category:
</p>
<p>
<%= select_tag "categories",
"<option>Team</option><option>Individual</option>"
%>
</p>
<div id="sel_con"></div>
<p>
<%= submit_tag "Show Sports" %>
</p>
<%= end_form_tag %>
#_options.rhtml:
<select id="<%= sptype %>" name="<%= sptype
%>">
<% sports.each do |sport| %>
<option><%= sport %></option>
<% end %>
</select>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---