# Rails Newbie question

**URL:** <https://www.ruby-forum.com/t/rails-newbie-question/103799>\
**Category:** Rails\
**Created:** [May 10, 2007, 1:45pm UTC](https://www.ruby-forum.com/t/rails-newbie-question/103799 "2007-05-10T13:45:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [May 10, 2007, 1:45pm UTC](https://www.ruby-forum.com/t/rails-newbie-question/103799/1 "2007-05-10T13:45:02Z")

</div>

I’ve got a div statement with id pets around a text box in my  
\_form.rhtml file. For this textbox, I want to show or hide based on  
if the user has selected something from a pulldown list. I’ve got an  
observe\_field that observes the collection\_select and updates the  
div. I defined the action in my controller, and also created a rjs  
file for the action. The question I have is how do i check the value  
from the select so i can show/hide the div based on the value from the  
select.

Thanks for any help,  
Jeff Cooper

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [May 10, 2007, 1:57pm UTC](https://www.ruby-forum.com/t/rails-newbie-question/103799/2 "2007-05-10T13:57:04Z")

</div>

Hey,

Imho no server is needed in this case, a simple javascript function  
would do hiding or showing a div depending on the value of some other  
control on the page.

Cheers,  
Yuri

On 5/10/07, Jeff [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks for any help,  
> Jeff Cooper
> 
> >

–  
Best regards,  
Yuri L.

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [May 10, 2007, 3:15pm UTC](https://www.ruby-forum.com/t/rails-newbie-question/103799/3 "2007-05-10T15:15:14Z")

</div>

Hi Jeff,

Jeff wrote:

> I’ve got an observe\_field that observes the collection\_select  
> and updates the div. I defined the action in my controller,  
> and also created a rjs file for the action. The question I have  
> is how do i check the value from the select so i can show/hide  
> the div based on the value from the select.

I’m not sure I’m understanding the current situation. You say you’ve  
“got  
an observe\_field that observes the collection\_select and updates the  
div”  
and then you ask “how do i check the value from the select so i can  
show/hide the div based on the value from the select”. Maybe it’s just  
‘not  
enough caffine yet’, but those two statements don’t seem to correllate.

To take a stab though, to send the value back from the observe\_field,  
use  
:with =\> ‘name\_you\_want\_the\_param\_to\_have’. The observe\_field will  
automatically populate the named param with the value of the field being  
observed. Do not use the :update option if you’re going to use an RJS  
template.

hth,  
Bill
