# Select in a loop

**URL:** <https://www.ruby-forum.com/t/select-in-a-loop/133133>\
**Category:** Rails\
**Created:** [March 28, 2008, 6:29am UTC](https://www.ruby-forum.com/t/select-in-a-loop/133133 "2008-03-28T06:29:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [March 28, 2008, 6:29am UTC](https://www.ruby-forum.com/t/select-in-a-loop/133133/1 "2008-03-28T06:29:41Z")

</div>

Hi  
My view code is

\<% for hardware\_ci in @hardware\_cis %\>

 \<%= select( "sd\_ci", "service\_desk\_ci\_association\_type\_id", ServiceDeskCiAssociationType.find(:all).collect {|p| [p.description, p.id] }) %\> \<%= hidden\_field "sd\_ci", "id", "value" =\> hardware\_ci.ci.id %\> \<% end %\>

\<% for document\_ci in @document\_cis %\>

 \<%= select( "sd\_ci", "service\_desk\_ci\_association\_type\_id", ServiceDeskCiAssociationType.find(:all).collect {|p| [p.description, p.id] }) %\> \<%= hidden\_field "sd\_ci", "id", "value" =\> document\_ci.ci.id %\> \<% end %\>

I am using submit\_to\_remote to submit this form.In controller I want to  
extract the pairs  
service\_desk\_ci\_association\_type\_id,hardware\_ci.ci.id and  
service\_desk\_ci\_association\_type\_id,document\_ci.ci.id.For example  
suppose there are total 10 items in the view and if only 2 of them are  
selected i need them. And save them to table.How can I do this.Please  
help.It is very urgent.

Sijo
