I''m trying to have a different image display on a page based on the
item
selected in a select pull-down menu.
collection_select(''game'', ''map_id'',
@themaps, :id, :name)
How do I get the index of @themaps that is selected?
Here''s what I have that doesn''t work:
<%= observe_field ''game_map_id'',
:update => :game,
:url => {:action => "newgame_select"},
:with => "''map_id=''+escape(value)" %>
<div id="newgame_select"></div>
in the gametype_controller.rb file:
def newgame_select
map_id = params[:map_id]
the_selection = @themaps[map_id]
end
I want to do something like this:
<img src=<%= @themaps[the_selection].imagepath %>
Will this work? Any ideas?
Thanks in advance,
-Matt
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails