How do you do ajax drop downs? I was looking over at
http://www.roryhansen.ca/?p=9
but couldn''t get it to work properly. I decided to try and use
form_remote, but it would submit the form instead of preformaing an ajax
call.
Since I need 2 form elemnts to preform an ajax calls, will they need to
be in seperate forms?
controller
test_update
@counties = County.find(:all,
:conditions => ["state = ?", params[:state_id]])
@html = “<select id=’county_id’ name=’county_id’>”
@html += “<option value=''’>select county</option>”
@counties.each do |cty|
@html += “<option value=’#{cty.id}’>#{cty.name}</option>”
end
@html += “</select>”
end
index
.. code to get state array, generate other stuff
end
index.rhtml
....
<form_remote_tag :html => {
url_for{:controller => "locator", action => test_update) }
%>
State
<select name=”state[state_id]” id=”state[state_id]”
onchange=form.submit() >
<option value=”">Select State</option>
<% @states.each do |state| %>
<option value=”<%= state.id %>”>
<%= state.name %>
</option>
<% end %>
</select>
<%= end_form_tag %>
County
<div id=”county_container”>
<select name=”county[county_id]” disabled=”disabled”>
<option value=”">Select County</option>
</select>
</div>
City
... the next form
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---