# Observe\_field to update render partial in a div

**URL:** <https://www.ruby-forum.com/t/observe-field-to-update-render-partial-in-a-div/125576>\
**Category:** Rails\
**Created:** [January 10, 2008, 9:43am UTC](https://www.ruby-forum.com/t/observe-field-to-update-render-partial-in-a-div/125576 "2008-01-10T09:43:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![suneeta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@suneeta](https://www.ruby-forum.com/u/suneeta)\
**Post date:** [January 10, 2008, 9:43am UTC](https://www.ruby-forum.com/t/observe-field-to-update-render-partial-in-a-div/125576/1 "2008-01-10T09:43:24Z")

</div>

Hey all,  
I’m trying to update a div everytime the value of my drop down box is  
changed:

 Type \<%= select("ci", "citype", CiType.find(:all).collect{|p| [p.name,p.id]})%\> 
 \<%= render :partial=\>'cipart/create\_hardware\_cis' %\>

\<%= observe\_field(“ci\_citype”,  
:update =\> “create\_ci\_container”,  
:url =\> { :controller =\> :create\_ci, :action =\> :create\_ci },  
:method =\> “post”,  
:with =\> “‘citype\_id=’+value”) %\>

The above code is written in view create\_ui.rhtml of ci\_controller.

The content in create\_ci\_controller:

class CreateCiController \< ApplicationController  
layout nil  
def create\_ci  
@ci\_type\_id = @params[“citype\_id”]  
end  
end

The content in create\_ci.rhtml is:

\<% if @ci\_type\_id == ‘2’ %\>  
\<%= render :partial=\>‘cipart/create\_software\_cis’ %\>  
\<% else %\>  
\<%= render :partial=\>‘cipart/create\_document\_cis’ %\>  
\<% end %\>

When I first load the page it renders cipart/create\_hardware\_cis in the  
div create\_ci\_container. The problem is when I change the value of the  
drop down box, the corresponding partial file is displayed and then the  
entire page disappeared immediately.

Please help me to solve this.

Regards  
Suneeta
