Rails Newbie question

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

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 [email protected] wrote:

Thanks for any help,
Jeff Cooper


Best regards,
Yuri L.

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