Form submit onchange of dropdown

Hi.,

Need help in learning how to submit a Form when a drop down value changes. I am using form_remote_tag . I want detail rows to be retrieved below automatically based on the value selected. ( Ex: Automatically list the students when you select the school name from the dropdown) . I am able to do it when I explicitly submit it using the submit_tag , but I want the form to be submitted as soon as the value changes with having to use the submit button. I am a newbie to Rails and would truly appreciate the help.

Thanks. Artybala

The best way to do this is to use the observe_field method.
Basically, you want to do this: (in the view)

Create a drop down:

<%= collection_select :user, :favorite_color, @colors, "id", "name %>

then somewhere below that, create an observe_field

<%= observe_field "user_favorite_color", :action => "do_something" %>

For more information, lookup collection_select and observe_field in
your favorite rails api format. I am partial to railsbrain:

collection_select: http://railsbrain.com/api/rails-1.2.4/doc/index.html?a=M001655&name=collection_select

observe_field: http://railsbrain.com/api/rails-1.2.4/doc/index.html?a=M001683&name=observe_field