Hi guys, I have a group of check box in rails page. check box Code as below: <% for count in @total_cellno %> <input name="checkbox" type="checkbox" value="<%= count %>" /> <% end %> I want to receive the selected value in my controller model. @selected_box << params["checkbox"] I guess that it provides values in a array. But @selected_box contains only one selected value. How can i capture all checked value in a array? Any idea? Please help me... Amin -- 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 -~----------~----~----~----~------~----~------~--~---
if you name your checkboxes like this <input name="checkbox[<%=count.to_s%>]" type="checkbox" value="1" /> you''ll get what you like Parameters: {"commit"=>"Do", "checkbox"=>{"1"=>"1", "3"=>"1"}} hint: there is a check_box_tag() helper ! Marcel On 25 Mai, 12:29, Amin <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi guys, > I have a group of check box in rails page. > check box Code as below: > <% for count in @total_cellno %> > <input name="checkbox" type="checkbox" value="<%= count %>" /> > <% end %> > > I want to receive the selected value in my controller model. > > @selected_box << params["checkbox"] > I guess that it provides values in a array. > But @selected_box contains only one selected value. > How can i capture all checked value in a array? > Any idea? > Please help me... > > Amin > > -- > 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 -~----------~----~----~----~------~----~------~--~---
lanzm wrote:> if you name your checkboxes like this > > <input name="checkbox[<%=count.to_s%>]" type="checkbox" value="1" /> > > you''ll get what you like > > Parameters: {"commit"=>"Do", "checkbox"=>{"1"=>"1", "3"=>"1"}} > > hint: there is a check_box_tag() helper ! > > MarcelHi Marcel, I use check_box_tag for check box ( according to ur hints) <% for count in @total_cellno %> <%= check_box_tag("checkbox", value = count, checked = false) %> <% end %> and in controller model I use following code to retrive the value in Hash: @total = params["checkbox"] In @total only one value is stored. Where is the problem? please take a hand. Thx in advanced. Amin -- 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 use check_box_tag for check box ( according to ur hints) > > <% for count in @total_cellno %> > <%= check_box_tag("checkbox", value = count, checked = false) %> > <% end %>I think you won''t get more than one if you name them all the same. Give it a name as I explained: <%= check_box_tag("checkbox[<%=count.to_s%>]", value = count, checked = false) %> or <%= check_box_tag("checkbox[]", value = count, checked = false) %> -- marcel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---