Get value of select whch change using ajax after form submit

Hi All,
I have a problem while updating select list using ajax and then submit
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.

<% 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’) %>

       <td >State</td>

       <td> <%= select_tag 'user_info[state]',

options_from_collection_for_select(@state, :state, :state,
@user_info.state) %>

<%= observe_field :user_info_state, :url
=>{:controller=>“logins”,:action =>‘select_city’, :id=>‘1’}, :update=>
‘city’ , :with => “’
:on=>‘click’ %>
   <tr id="city">

    <td >City</td>

   <td><%= collection_select :user_info, :city,  @cities ||, :city, :city, :prompt=>true %>


<% end %>

controller method
def edit_city
@cities = UsaCity.find(:all, :conditions=>[“state=?”,
@type = params[:type]
render :update do |page|
page.replace_html ‘city’, :partial => ‘logins/select_city’,
:object=>[@cities, @type], :layout => false


City1345 <%= collection_select :user_info, :city, @cities ||, :city, :city, :prompt=>true %>

Salil G.

Hi All,

Sorry for this but it’s not working properly because i use form_for tag
inside the

i only remove form from inside the table and keep outside the table tag
and now everything is works like a magic. I hope this will help someone
to save his/her 1 hr or 2.


Salil G.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs