I''m testing a small bit of functionality using RJS. I have a form with a radio-button set -- a Yes button and No button -- and a text input. I''m using observe_form to send the entire form to the server, instead of observe_field. What I''d like to happen is to have the text input hidden if I click Yes and the text input displayed if I click No. In order to decide what action to perform -- show or hide -- I need to know the value of the radio button. I imagine that my rjs template would look something like this if value_of_radio == "Yes" page["textinput"].hide else page["textinput"].Show end I just don''t know how to get that value_of_radio populated. Any suggestions or pointers will be much appreciated. It could be that I''m missing something simple, or maybe I''m going about this all wrong. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 11, 2007 9:50 AM, Ian <ian.m.whitney-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m testing a small bit of functionality using RJS. I have a form with > a radio-button set -- a Yes button and No button -- and a text input. > > I''m using observe_form to send the entire form to the server, instead > of observe_field. > > What I''d like to happen is to have the text input hidden if I click > Yes and the text input displayed if I click No. > > In order to decide what action to perform -- show or hide -- I need to > know the value of the radio button. I imagine that my rjs template > would look something like this > > if value_of_radio == "Yes" > page["textinput"].hide > else > page["textinput"].Show > endThe input values will be in params[], just like with any other request. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Are you sending the request to the server simply so you can hide or unhide a field? If so you should just use js and an onclick event. On Dec 11, 6:50 am, Ian <ian.m.whit...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m testing a small bit of functionality using RJS. I have a form with > a radio-button set -- a Yes button and No button -- and a text input. > > I''m using observe_form to send the entire form to the server, instead > of observe_field. > > What I''d like to happen is to have the text input hidden if I click > Yes and the text input displayed if I click No. > > In order to decide what action to perform -- show or hide -- I need to > know the value of the radio button. I imagine that my rjs template > would look something like this > > if value_of_radio == "Yes" > page["textinput"].hide > else > page["textinput"].Show > end > > I just don''t know how to get that value_of_radio populated. > > Any suggestions or pointers will be much appreciated. It could be that > I''m missing something simple, or maybe I''m going about this all wrong.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Looking at the API you can keep the observe_form tag and pass it a
straight JS function.
observe_field("glass", :frequency => 1, :function =>
"alert(''Element
changed'')")
On Dec 11, 8:37 am, Richard Luther
<richard.lut...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Are you sending the request to the server simply so you can hide or
> unhide a field? If so you should just use js and an onclick event.
>
> On Dec 11, 6:50 am, Ian
<ian.m.whit...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:>
I''m testing a small bit of functionality using RJS. I have a form with
> > a radio-button set -- a Yes button and No button -- and a text input.
>
> > I''m using observe_form to send the entire form to the server,
instead
> > of observe_field.
>
> > What I''d like to happen is to have the text input hidden if I
click
> > Yes and the text input displayed if I click No.
>
> > In order to decide what action to perform -- show or hide -- I need to
> > know the value of the radio button. I imagine that my rjs template
> > would look something like this
>
> > if value_of_radio == "Yes"
> > page["textinput"].hide
> > else
> > page["textinput"].Show
> > end
>
> > I just don''t know how to get that value_of_radio populated.
>
> > Any suggestions or pointers will be much appreciated. It could be that
> > I''m missing something simple, or maybe I''m going
about this all wrong.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thanks for this reply. I couldn''t get the params thing to work until I read this thread: http://www.ruby-forum.com/topic/81608 Now it''s looking good. Appreciate it! On Dec 11, 11:08 am, "Bob Showalter" <showa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Dec 11, 2007 9:50 AM, Ian <ian.m.whit...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > I''m testing a small bit of functionality using RJS. I have a form with > > a radio-button set -- a Yes button and No button -- and a text input. > > > I''m using observe_form to send the entire form to the server, instead > > of observe_field. > > > What I''d like to happen is to have the text input hidden if I click > > Yes and the text input displayed if I click No. > > > In order to decide what action to perform -- show or hide -- I need to > > know the value of the radio button. I imagine that my rjs template > > would look something like this > > > if value_of_radio == "Yes" > > page["textinput"].hide > > else > > page["textinput"].Show > > end > > The input values will be in params[], just like with any other request.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---