RoR AJAX select box update?

Hi,

I want to update a select box depending on another selected option thru
ajax.

Heres how I do it

_form.rhtml

<select id=“budget_coordinator_id” name=“budget[coordinator_id]”
onchange="<%= remote_function(:update => “budget_project_number”, :url
=> { :action => :get_projects }) %>">
<%= options_from_collection_for_select(Coordinator.find_all, “id”,
“coordinator_name”) %>

#get_projects
def get_projects
@results = Project.find_all
render :partial => ‘options’
end

_options.rhtml

<% for project in @results do -%>

<%=project.project_number%> <% end -%>

This somehow seem to work in firefox, but not in IE. also the ajax calls
returns the whole options tag… instead of this, can we just return the
result object and then populate the select on the client side?

Advanced Thanx for any help!

Sandosh

On 1/7/06, Sandosh [email protected] wrote:

onchange="<%= remote_function(:update => “budget_project_number”, :url
#get_projects
<% end -%>

This somehow seem to work in firefox, but not in IE. also the ajax calls
returns the whole options tag… instead of this, can we just return the
result object and then populate the select on the client side?

Let me know if you find out the answer… I’d also like to know this.

This has been asked many times and I think the best resource so far is
Rory
Hansen’s "Rory on Rails " article.
http://www.roryhansen.ca/?p=9
It is actually quite simple if you learn to use the link_to_remote and
the
observe_field macros or better still master the prototype library and
use
Javascript directly.