related drop list

1. new.rhtml

<h1>New pr_cate</h1> <%= javascript_include_tag 'prototype' %> <% form_for(@pr_cate) do |f| %> <%= f.error_messages %>

<p>

<%=f.select(:id, @pr_cates.map {|u| [u.name,u.id]}, {:onchange => remote_function( :with => "'id='+value", :method => "get", :update => 'next_select', :url => { :action => :new } ) }

)%> <div id='next_select'> <%= render(:partial => "test") %> </div>

...

2. controller

def new

if params[:id] @pr_cates = PrCate.find(:all, :conditions => ["parent_id = ?", params[:id]]) else @pr_cates = PrCate.find(:all, :conditions => ["parent_id = ?", "0"]) end

@pr_cate = PrCate.new

respond_to do |format| format.html # new.html.erb format.xml { render :xml => @pr_cate } end end

3. _test.rhtml

<%= select("pr_cate","id", @pr_cates.map {|u| [u.name,u.id]}) %>

Now the second drop list is not working correct.