Retrieve selected value from <%=select()%>


#1

Hi, I’m learning ruby on rails at the moment so please consider if this
is a silly problem. I have a index.rhtml file where the combo box lies.
When this combo box with different areas changes it updates another
combo box within the same file and displays all the campsites in that
area. For this I’ve written:

index.rhtml

<%= select(:selected, :location, GreatWalk.getAvailableLocations, {:prompt => 'Select a category'}, :id => :id_selected) %>

<%= observe_field :id_selected, :url => {:action =>
:update_campsites}, :update => :campsites, :with => “walk_id” %>

<%form_for :booking, :url => {:action => :save_bookings} do |form|%>
<%=form.select "camp_id", Campsite.getAvailableCamps%>
<%=submit_tag "Get Camp And Save"%> <%end%> --------------------------------------------------------------------------------

update_campsites.rhtml

<%=select "selected", "camp_id", @campholder %>
--------------------------------------------------------------------------------

The problem is, no way in the world, I could get the selected campsite.
I tried @booking=Booking.new(params[:booking]) and then (print
@booking.camp_id) in the save_bookings action in the controller, it
shows nil. I also tried putting @camp=params[“selected”][“camp_id”] and
then (print @camp )in update_campsites action in controller but gives
error instead. Also after I click the button and change the first combo
box value it doesn’t trigger any update to the second combo box. So,
please help me find what I’m doing wrong here and how I can get that
selected value, that would be so great. thanks

regards,
Jay