Hi,

I have some issues with setting the selected value. On my page, user 
selects a State from the drop down and other attributes and click on 
"Find". I want to set the default value of the drop down to the value 
selected prior to clicking "Find".

<%=collection_select(:state, :state_id, @states, :state_id, :state_name,
          {:prompt => true,  :selected => @selected_state},
          {:style => 'width:200px;',
               :onchange => remote_function(:url =>
                 {:action => 'update_cities'},:with => 
"'state_id='+value")})%>

In my controller, if I have @selected_state = 1, the dropdown default 
value is shown in the UI. However,  if I have @selected_state = 
state_id, the default value is not set.

Snippet of the code in my controller:

def find
    state_id = params[:state][:state_id]

    @selected_state = state_id

    /* Some logic here */

    @states = State.find(:all)

   respond_to do |format|
        format.html { render :action => "index" }
   end
 end

Any pointers are appreciated. Thanks.

-- 
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to