# Observe\_field and update

**URL:** <https://www.ruby-forum.com/t/observe-field-and-update/103351>\
**Category:** Rails\
**Created:** [May 4, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/observe-field-and-update/103351 "2007-05-04T16:40:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimache](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c67d28/32.png) [@jimache](https://www.ruby-forum.com/u/jimache)\
**Post date:** [May 4, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/observe-field-and-update/103351/1 "2007-05-04T16:40:51Z")

</div>

Hi everyone,

I have a select box with an observe field; i update another select box  
on first ones change. Is there a way to update more than one select  
box on change. I need to update 2 select boxes based on the selection  
of the first one. Any input is appreciated

Thank you,

---

<div class="post-metadata">

**Author:** ![jimache](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c67d28/32.png) [@jimache](https://www.ruby-forum.com/u/jimache)\
**Post date:** [May 4, 2007, 5:13pm UTC](https://www.ruby-forum.com/t/observe-field-and-update/103351/2 "2007-05-04T17:13:53Z")

</div>

can you paste some of your code?

---

<div class="post-metadata">

**Author:** ![jimache](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c67d28/32.png) [@jimache](https://www.ruby-forum.com/u/jimache)\
**Post date:** [May 4, 2007, 6:35pm UTC](https://www.ruby-forum.com/t/observe-field-and-update/103351/3 "2007-05-04T18:35:00Z")

</div>

Hi,

> I have a select box with an observe field; i update another select box  
> on first ones change. Is there a way to update more than one select  
> box on change. I need to update 2 select boxes based on the selection  
> of the first one. Any input is appreciated

sure you can do that. When you call observe\_field you usually have the  
:update parameter filled in, which means “write the return of the action  
to the element with this id”.

when you want to update multiple elements with an ajax call, what you do  
is just not provide an :update parameter.

That way, the ajax called is managed in a slightly different way. In  
that case, you will have in your rjs (or in your action by using render  
:update) an object called “page” which represents your document object  
in javascript.

you could do something like  
page.replace\_html id\_of\_the\_first\_dependant\_box, :partial=\>whatever  
page.replace\_html id\_of\_the\_second\_dependant\_box,  
:partial=\>whatever

regards,

javier ramirez

## –

Estamos de estreno… si necesitas llevar el control de tus gastos  
visita [http://www.gastosgem.com](http://www.gastosgem.com) !!Es gratis!!
