# Need help with check boxes

**URL:** <https://www.ruby-forum.com/t/need-help-with-check-boxes/110607>\
**Category:** Rails\
**Created:** [July 28, 2007, 12:20am UTC](https://www.ruby-forum.com/t/need-help-with-check-boxes/110607 "2007-07-28T00:20:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 28, 2007, 12:20am UTC](https://www.ruby-forum.com/t/need-help-with-check-boxes/110607/1 "2007-07-28T00:20:10Z")

</div>

Hello everybody,

I have created check box in an rhtml file and want to have its id and  
name of all the items that are checked, in controller class that it is  
linked to…how can i get it? This is my scenario in rhtml file…

\<% i = 0 %\>  
\<% @hotels.each do |hotel| %\>

\<input type=“checkbox” id="\<%=hotel.group\_name%\>\_\<%=i%\>" name="\<  
%=hotel.group\_name%\>[\<%=i%\>]" value= “\<%=i%\>” onclick=“submit”

> Wanna…Aproove?

\<% i = i + 1 %\>  
\<% end %\>

The value of @hotels, i am getting from controller where one of the  
column is group\_name.  
So how can get the id, name and value of the items checked in the  
concern controller class(admin).  
Any help would be really appreciated,  
thanks in advance,  
Czar

Online

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 28, 2007, 1:46am UTC](https://www.ruby-forum.com/t/need-help-with-check-boxes/110607/2 "2007-07-28T01:46:19Z")

</div>

Why are you using an artificial counter (i) rather than the id column  
of the hotel?

I would suggest this Wiki article as a good place to look for a  
variety of suggestions  
[http://wiki.rubyonrails.org/rails/pages/CheckboxHABTM](http://wiki.rubyonrails.org/rails/pages/CheckboxHABTM)
