Hi All, I have a problem while updating select list using ajax and then submit it. what i have done is to change the drop down of a city when i changed the state.but when i am submitting the form i am not able to get the value of city. Following is my code for the same.
edit.html.erb <% form_for :user_info , :url=>{:controller=>"users", :action=>"update_contact_details",:id=>params[:id] } do |f| %> <% @state= UsaCity.find_by_sql('select DISTINCT state from usa_cities') %> <tr> <td >State</td> <td> <%= select_tag 'user_info[state]', options_from_collection_for_select(@state, :state, :state, @user_info.state) %><div id="user_sate_loading" style="display:none"><img src="/images/loading.gif"></div> <br><span id="stateError" class="error"></span> <%= observe_field :user_info_state, :url =>{:controller=>"logins",:action =>'select_city', :id=>'1'}, :update=> 'city' , :with => "' state='+document.getElementById('user_info_state').value+'&type=contact_details'", :on=>'click' %> </td> </tr> <tr id="city"> <td >City</td> <td><%= collection_select :user_info, :city, @cities || Array.new, :city, :city, :prompt=>true %><br><span id="cityError" class="error"></span></td> </tr> <% end %> controller method def edit_city @cities = UsaCity.find(:all, :conditions=>["state=?", params[:state]]) @type = params[:type] render :update do |page| page.replace_html 'city', :partial => 'logins/select_city', :object=>[...@cities, @type], :layout => false end end _select_city.html.erb <td>City1345</td> <td><%= collection_select :user_info, :city, @cities || Array.new, :city, :city, :prompt=>true %><br><span id="cityError" class="error"></span></td> Regards, Salil Gaikwad -- 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 -~----------~----~----~----~------~----~------~--~---