# Observe\_field

**URL:** <https://www.ruby-forum.com/t/observe-field/126675>\
**Category:** Rails\
**Created:** [January 21, 2008, 10:23am UTC](https://www.ruby-forum.com/t/observe-field/126675 "2008-01-21T10:23:23Z")\
**Posts on this page:** 5\
**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 21, 2008, 10:23am UTC](https://www.ruby-forum.com/t/observe-field/126675/1 "2008-01-21T10:23:23Z")

</div>

Hi…  
I’m trying to update the content in a div while the value of a hidden  
field is changed.

\<%= hidden\_field “location”, “id”, “value” =\> 0 %\>

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

There is no response. But when I replaced the hidden\_field with a  
select, it worked. I need to implement the observe\_field with  
hidden\_field itself. Please help me…

---

<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 21, 2008, 10:28am UTC](https://www.ruby-forum.com/t/observe-field/126675/2 "2008-01-21T10:28:18Z")

</div>

When you test this…  
is the request going out  
how are you changing the hidden field?

---

<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 21, 2008, 10:52am UTC](https://www.ruby-forum.com/t/observe-field/126675/3 "2008-01-21T10:52:38Z")

</div>

Keynan P. wrote:

> When you test this…  
> is the request going out  
> how are you changing the hidden field?

There is a link called choose location. When I click on it, a popup box  
for selecting the location is shown. When I click on one location, the  
value of the hidden field will be changed.  
The code for changing the value of the hidden\_field is given below:

In the view search\_ci\_location.rhtml under popup controller:

\<%=  
location.street %\>

---

<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 22, 2008, 5:05am UTC](https://www.ruby-forum.com/t/observe-field/126675/4 "2008-01-22T05:05:17Z")

</div>

brewpoo wrote:

> I don’t think that will trigger correctly. Can’t you add an Ajax  
> request to the setLocation function directly?
> 
> On Jan 21, 4:52 am, Suneeta Km [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Can u please show me an example of how to do this?

---

<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 21, 2008, 3:26pm UTC](https://www.ruby-forum.com/t/observe-field/126675/5 "2008-01-21T15:26:22Z")

</div>

I don’t think that will trigger correctly. Can’t you add an Ajax  
request to the setLocation function directly?

On Jan 21, 4:52 am, Suneeta Km [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
