Forum: Ruby on Rails Rails Newbie question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
159d8bd80fa3703e2cc27a66b5a1220f?d=identicon&s=25 Jeff (Guest)
on 2007-05-10 13:45
(Received via mailing list)
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
8d1e089fd6a6703f5f13dbee271aa77c?d=identicon&s=25 Yuri Leikind (Guest)
on 2007-05-10 13:57
(Received via mailing list)
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 <jscooper@gmail.com> wrote:
> Thanks for any help,
> Jeff Cooper
>
>
> >
>


--
Best regards,
Yuri Leikind
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2007-05-10 15:15
(Received via mailing list)
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
This topic is locked and can not be replied to.