Hi Patrick,

if i understand correctly you want to have 2 select boxes that are 
depending. So the second one changes it's content mased on the first one 
...

Took me some time to find out ...

The trick was to put the second select into it's own partial :

the view would look like this :
[code]
<label><%=h('1st Selectbox')%></label>
<%= @departments = Department.find(:all, :order => "name")
      collection_select('depart', 'department_id', @departments, :id, 
:name, :include_blank => true)  %>
      <br />
      <label><%=h('2nd Selectbox')%></label>
     <div id="taskselect"
       <%= render(:partial => 'taskselect') %>
    </div>

      <%= observe_field 'depart_department_id',:update => 
'taskselect',:url => {:action => 'change_taskgroup'},:with => 
'depart_department_id'%>
[/code]

if the first collection_select changes it the "observe_field" will call 
the controller action 'change_taskgroup' with parameter 
'depart_department_id' (that's the value of the selected item in 
selectbox 1) and the re-render the div taskselect.

[code]
  def change_taskgroup
    @varDepartment = params[:depart_department_id]
    @categories = Taskcategory.by_department(@varDepartment)
    render :partial => 'taskselect', :layout => false
  end
[/code]

the controller will fetch the new categories and "re-render" the div 
taskselect with new values.


Hope that helped

best regards
Alex

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to