RE: Linking two HTML SELECT's together


#1

Here’s what I did… Very hastily hacked from an existing program:

View page:

<%=options_from_collection_for_select(@projects, "id", "name", params['pid'].to_i )%> Select a project.

controller:

def ajax_project_members
res = “”
p = Project.find(id, :include=>[:teammembers]) rescue nil
if p.nil?
res = ‘Choose a project’
else
res += "
res += options_from_collection_for_select p.teammembers, “id”,
“name”
res +=""
end
return result

end

Looking at this now, I notice it could be done a little differently (you
could just use <%select %> instead of options_from_collection… But
this still works. (this was originally for a form that had multiple
tasks that you could move to a different project.)