I want to hide elements of a form from users untill they click on a radio button. Any pointers? Thanks in advance - K --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
How you are generating the radio buttons? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
radio_button_tag - since it is not associated with a model On Jan 25, 12:27 pm, Mark Dodwell <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> How you are generating the radio buttons? > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ok, can you just insert some javascript into the onclick method: radio_button_tag ''foo'', ''foo'', false, :onclick => ''show_hide_appropriate_layer()'' -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yes .. but what does the show_hide function look like? Thats were I am having trouble. Thanks -K On Jan 25, 12:41 pm, Mark Dodwell <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Ok, can you just insert some javascript into the onclick method: > > radio_button_tag ''foo'', ''foo'', false, :onclick => > ''show_hide_appropriate_layer()'' > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This is what Ihave tried - still not working:
in .rhtml (a partial)
<%= radio_button_tag ''save'',1, checked =
false, options {:onclick => ''show_hidden_div''} %>
<label for="saved_name" >Save To My
Modules:</label>
<div id = "save_module",
style="display:none;">
<label for="saved_name" >Save As:</label>
<%= text_field ''mod'',
''saved_name'' %>
</div>
In application.js:
function show_hidden_div(){
if (document.getElementById) {
var save = form.save;
if (save[0].checked) {
document.getElementById("save_module").style.display =
"block";
}
}
}
On Jan 25, 12:46 pm, "Kim"
<Kim.Gri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Yes .. but what does the show_hide function look like? Thats were I am
> having trouble.
>
> Thanks -K
>
> On Jan 25, 12:41 pm, Mark Dodwell
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
> wrote:
>
> > Ok, can you just insert some javascript into the onclick method:
>
> > radio_button_tag ''foo'', ''foo'',
false, :onclick =>
> > ''show_hide_appropriate_layer()''
>
> > --
> > Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
It''s a bit rough but something like this should work ok:
--
<%= radio_button_tag ''radios'', ''one'',
false,
:onclick => ''toggle(this.value)'' %>
<label for="one">One</label><br />
<%= radio_button_tag ''radios'', ''two'',
false,
:onclick => ''toggle(this.value)'' %>
<label for="two">Two</label><br />
<%= radio_button_tag ''radios'', ''three'',
false,
:onclick => ''toggle(this.value)'' %>
<label for="three">Three</label><br />
<%= radio_button_tag ''radios'', ''four'',
false,
:onclick => ''toggle(this.value)'' %>
<label for="four">Four</label><br />
<div id="info_one" style="display: none;">Hello from
info 1!</div>
<div id="info_two" style="display: none;">Hello from
info 2!</div>
<div id="info_three" style="display: none;">Hello from
info 3!</div>
<div id="info_four" style="display: none;">Hello from
info 4!</div>
<script type="text/javascript">
function toggle(value) {
get_element_by_id(''info_one'').style.display =
''none'';
get_element_by_id(''info_two'').style.display =
''none'';
get_element_by_id(''info_three'').style.display =
''none'';
get_element_by_id(''info_four'').style.display =
''none'';
get_element_by_id(''info_''+value).style.display =
''block'';
}
function get_element_by_id(id) {
return document.getElementById(id);
}
</script>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
I got it to work - thanks :) On Jan 25, 1:24 pm, Mark Dodwell <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> It''s a bit rough but something like this should work ok: > -- > > <%= radio_button_tag ''radios'', ''one'', false, > :onclick => ''toggle(this.value)'' %> > <label for="one">One</label><br /> > > <%= radio_button_tag ''radios'', ''two'', false, > :onclick => ''toggle(this.value)'' %> > <label for="two">Two</label><br /> > > <%= radio_button_tag ''radios'', ''three'', false, > :onclick => ''toggle(this.value)'' %> > <label for="three">Three</label><br /> > > <%= radio_button_tag ''radios'', ''four'', false, > :onclick => ''toggle(this.value)'' %> > <label for="four">Four</label><br /> > > <div id="info_one" style="display: none;">Hello from info 1!</div> > <div id="info_two" style="display: none;">Hello from info 2!</div> > <div id="info_three" style="display: none;">Hello from info 3!</div> > <div id="info_four" style="display: none;">Hello from info 4!</div> > > <script type="text/javascript"> > function toggle(value) { > get_element_by_id(''info_one'').style.display = ''none''; > get_element_by_id(''info_two'').style.display = ''none''; > get_element_by_id(''info_three'').style.display = ''none''; > get_element_by_id(''info_four'').style.display = ''none''; > get_element_by_id(''info_''+value).style.display = ''block''; > } > function get_element_by_id(id) { > return document.getElementById(id); > } > </script> > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---