Hello I have a view which have 2 radio buttons : ... <td style="width:5%">Actuel</td> <td style="width:10%"><%= radio_button_tag(:actuel, value = "1", checked = false, options = {}) %> <td style="width:5%">Last</td> <td style="width:10%"><%= radio_button_tag(:last, value = "1", checked false, options = {}) %></td> ... I dont know how to proceed to control the status of my radio buttons. When I click on the first one, i want to put the 2nd unchecked. When I click on the 2nd one I want to uncheck the first one. I know how to to it using html radio buttons + javascript. But using radio_button_tag I dont know how to proceed. Anyone can help me please? thanks regards -- 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 -~----------~----~----~----~------~----~------~--~---
<cliveharber-q/Bov5K/xQpeoWH0uzbU5w@public.gmane.org>
2007-Oct-11 13:09 UTC
Re: radio_button_tag
Hi Radio buttons need to belong to the same group to be able to work together. In your code you have two different groups, or attributes, :actuel and :last. These need to be the same - the general form of the radio_button_tag helper is: radio_button_tag(:attribute, tag_value, options). You can then determine which one was pressed when the form is submitted by the value of the button given in the params hash HTH Clive ---- Paulo Carvalho <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hello > > I have a view which have 2 radio buttons : > > ... > <td style="width:5%">Actuel</td> > <td style="width:10%"><%= radio_button_tag(:actuel, value = "1", checked > = false, options = {}) %> > <td style="width:5%">Last</td> > <td style="width:10%"><%= radio_button_tag(:last, value = "1", checked > false, options = {}) %></td> > ... > > I dont know how to proceed to control the status of my radio buttons. > When I click on the first one, i want to put the 2nd unchecked. When I > click on the 2nd one I want to uncheck the first one. > > I know how to to it using html radio buttons + javascript. But using > radio_button_tag I dont know how to proceed. > Anyone can help me please? > > thanks > regards > -- > 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 -~----------~----~----~----~------~----~------~--~---
unknown wrote:> Hi > > Radio buttons need to belong to the same group to be able to work > together. In your code you have two different groups, or attributes, > :actuel and :last. These need to be the same - the general form of the > radio_button_tag helper is: > radio_button_tag(:attribute, tag_value, options). You can then determine > which one was pressed when the form is submitted by the value of the > button given in the params hash > > HTH > > CliveHello Thanks for your answer. I had put the radio buttons with the same name to be on the same group. <td style="width:5%">actuel</td> <td style="width:10%"><%= radio_button_tag(:type_recherche, value = "1", checked = false, options = {}) %> <td style="width:5%">last</td> <td style="width:10%"><%= radio_button_tag(:type_recherche, value = "2", checked = false, options = {}) %></td> To pass the values I use a link_to_remote: <%= link_to_remote "Rechercher", :update => "resultlist", :url => { :action => ''rechercher''}, :with => "...+ ''&'' + ''type_recherche='' + $F(''type_recherche'')", :complete => visual_effect(:appear, ''resultlist'', :duration => 1.00) %> In my controller when i try to access to the "type_recherche" value (my 2 radio buttons), I do this: if params[:type_recherche].nil? puts "1" @demand.type_recherche = "0" else if params[:type_recherche].to_s == ''null'' @demand.type_recherche = "0" else puts "6 -> " + params[:type_recherche].to_s @demand.type_recherche = params[:type_recherche] end end When i check the first radio it works fine. I receive the value "1". But when i check the second radio button, i always receive null. It seems that the only radio button used is the first one. Any idea about this problem. Thanks -- 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 -~----------~----~----~----~------~----~------~--~---
Paulo Carvalho wrote:> Hello > > I have a view which have 2 radio buttons : > > ... > <td style="width:5%">Actuel</td> > <td style="width:10%"><%= radio_button_tag(:actuel, value = "1", checked > = false, options = {}) %> > <td style="width:5%">Last</td> > <td style="width:10%"><%= radio_button_tag(:last, value = "1", checked > false, options = {}) %></td> > ... > > I dont know how to proceed to control the status of my radio buttons. > When I click on the first one, i want to put the 2nd unchecked. When I > click on the 2nd one I want to uncheck the first one. > > I know how to to it using html radio buttons + javascript. But using > radio_button_tag I dont know how to proceed. > Anyone can help me please? > > thanks > regardsI had put the radio buttons with the same name to be on the same group. <td style="width:5%">actuel</td> <td style="width:10%"><%= radio_button_tag(:type_recherche, value = "1", checked = false, options = {}) %> <td style="width:5%">last</td> <td style="width:10%"><%= radio_button_tag(:type_recherche, value = "2", checked = false, options = {}) %></td> To pass the values I use a link_to_remote: <%= link_to_remote "Rechercher", :update => "resultlist", :url => { :action => ''rechercher''}, :with => "...+ ''&'' + ''type_recherche='' + $F(''type_recherche'')", :complete => visual_effect(:appear, ''resultlist'', :duration => 1.00) %> In my controller when i try to access to the "type_recherche" value (my 2 radio buttons), I do this: if params[:type_recherche].nil? puts "1" @demand.type_recherche = "0" else if params[:type_recherche].to_s == ''null'' @demand.type_recherche = "0" else puts "6 -> " + params[:type_recherche].to_s @demand.type_recherche = params[:type_recherche] end end When i check the first radio it works fine. I receive the value "1". But when i check the second radio button, i always receive null. It seems that the only radio button used is the first one. Any idea about this problem. Thanks -- 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 -~----------~----~----~----~------~----~------~--~---