Topic: rjs problem (error displaying)

hi!
i'm heaving a big problem 'displaying' a select field that depends on selection of the previous select field. Now i'm stuck on the next thing. on the picture below you can see that when i select something in the first list (red outline) the second one (blue outline) is generated and shown. I just think it is shown on screen as a part of java error (2 times)??. Otherwise it works perfectly smile its just the text around that is bugging me ("try { new Insertion.Top..."). I know nothing about java and too little about rails rjs to fix this so i'm asking for your help.

http://freeweb.siol.net/bokrajnc/select_error_1.jpg
example 1

http://freeweb.siol.net/bokrajnc/select_error_2.jpg
example 2

Here is the relevant code..it is messy, because i was trying to fix this and was changing it a lot.

#_form.rhtml (part)
<div class="form-element_customer">
<select id="customerId" name="customer" onChange=
    "<%= remote_function(:url => {:action => :update_projects}, :with => "this.value", :update => 'projectId') %>">
    <% for cust in @customers  %>
        <option value=<%= cust.id %>><%= cust.desc %></option>
    <% end  %>
</select>
</div>

<div class="form-element_project">
<div id="projectId">
</div>
</div>


#_form2.rhtml
<select>
    <% for project in @projects %>
        <option value=<%= project.id %>><%= project.desc %></option>
    <% end %>
</select>

#hours_controller.rb (part)
def update_projects
    $temp = request.params.keys.first
    @customers = session[:user].validCustomers()
    @projects = Project.find(:all, :conditions => ['user_id = ? AND customer_id = ?',session[:user].id, $temp])
    return render(:action => 'update_projects.rjs') if request.xhr?
  end

#update_projects.rjs
page.insert_html :top, "projectId", :partial => "form2"

I would REALLY appreciate your help.

Re: rjs problem (error displaying)

You shouldn't pass the :update parameter while using RJS:

<%= remote_function(:url => {:action => :update_projects}, :with => "this.value") %>

That should fix it.

Railscasts - Free Ruby on Rails Screencasts