wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-02 16:31 UTC
Display text_field if checkbox checked
Hi! I''ve been trying to figure out how to display a text_field if a checkbox on my form is checked. If the checkbox is unchecked, the text_field is removed. If anybody has an example or tutorial on this, that would be great. I''m going to do some more searching in google now and not the group...but if anybody can help, that would be awesome. Thanks, mike --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
something like this ought to do it: <%= check_box :foo, :box, :onclick => "document.getElementById(''foo_bar'').style.display = (this.checked ? ''inline'' : ''none'');" %> <%= text_field :foo, :bar, :style => ((params[:foo] and params[:foo] [:box] == ''1'') ? ''display:inline'' : ''display:none'') %> On Aug 2, 12:31 pm, "wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi! > > I''ve been trying to figure out how to display a text_field if a > checkbox on my form is checked. If the checkbox is unchecked, the > text_field is removed. > > If anybody has an example or tutorial on this, that would be great. > I''m going to do some more searching in google now and not the > group...but if anybody can help, that would be awesome. > > Thanks, > mike--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-03 14:37 UTC
Re: Display text_field if checkbox checked
Wow, thank you so very much. That worked!!!! Thank you again, this will come in very handy! Mike On Aug 2, 9:11 pm, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> something like this ought to do it: > > <%= check_box :foo, :box, :onclick => > "document.getElementById(''foo_bar'').style.display = (this.checked ? > ''inline'' : ''none'');" %> > <%= text_field :foo, :bar, :style => ((params[:foo] and params[:foo] > [:box] == ''1'') ? ''display:inline'' : ''display:none'') %> > > On Aug 2, 12:31 pm, "wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi! > > > I''ve been trying to figure out how to display a text_field if a > > checkbox on my form is checked. If the checkbox is unchecked, the > > text_field is removed. > > > If anybody has an example or tutorial on this, that would be great. > > I''m going to do some more searching in google now and not the > > group...but if anybody can help, that would be awesome. > > > Thanks, > > mike--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-03 14:54 UTC
Re: Display text_field if checkbox checked
I don''t mean to be a pain...i''m really greatful that you took the time to help me out. But, is there also a way I can display a snippet of text when the text_field pops up as well? thanks again for your help! mike On Aug 3, 9:37 am, "wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Wow, thank you so very much. That worked!!!! > > Thank you again, this will come in very handy! > > Mike > > On Aug 2, 9:11 pm, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > something like this ought to do it: > > > <%= check_box :foo, :box, :onclick => > > "document.getElementById(''foo_bar'').style.display = (this.checked ? > > ''inline'' : ''none'');" %> > > <%= text_field :foo, :bar, :style => ((params[:foo] and params[:foo] > > [:box] == ''1'') ? ''display:inline'' : ''display:none'') %> > > > On Aug 2, 12:31 pm, "wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi! > > > > I''ve been trying to figure out how to display a text_field if a > > > checkbox on my form is checked. If the checkbox is unchecked, the > > > text_field is removed. > > > > If anybody has an example or tutorial on this, that would be great. > > > I''m going to do some more searching in google now and not the > > > group...but if anybody can help, that would be awesome. > > > > Thanks, > > > mike--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-03 16:42 UTC
Re: Display text_field if checkbox checked
For others, I figured it out. It seems to work the same... --- Response: <%= check_box :response, :sens_class, :onclick => "document.getElementById(''response_cscs'').style.display (this.checked ? ''inline'' : ''none'');" %> <div id="response_cscs" style="display:none"> CSCS #: <%= text_field :response, :cscs %> </div> ---- On Aug 3, 9:54 am, "wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I don''t mean to be a pain...i''m really greatful that you took the time > to help me out. > > But, is there also a way I can display a snippet of text when the > text_field pops up as well? > > thanks again for your help! > mike > > On Aug 3, 9:37 am, "wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Wow, thank you so very much. That worked!!!! > > > Thank you again, this will come in very handy! > > > Mike > > > On Aug 2, 9:11 pm, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > something like this ought to do it: > > > > <%= check_box :foo, :box, :onclick => > > > "document.getElementById(''foo_bar'').style.display = (this.checked ? > > > ''inline'' : ''none'');" %> > > > <%= text_field :foo, :bar, :style => ((params[:foo] and params[:foo] > > > [:box] == ''1'') ? ''display:inline'' : ''display:none'') %> > > > > On Aug 2, 12:31 pm, "wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi! > > > > > I''ve been trying to figure out how to display a text_field if a > > > > checkbox on my form is checked. If the checkbox is unchecked, the > > > > text_field is removed. > > > > > If anybody has an example or tutorial on this, that would be great. > > > > I''m going to do some more searching in google now and not the > > > > group...but if anybody can help, that would be awesome. > > > > > Thanks, > > > > mike--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---