# How to use input control in loop

**URL:** <https://www.ruby-forum.com/t/how-to-use-input-control-in-loop/168287>\
**Category:** Rails\
**Created:** [May 19, 2009, 8:07am UTC](https://www.ruby-forum.com/t/how-to-use-input-control-in-loop/168287 "2009-05-19T08:07:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nishi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@nishi](https://www.ruby-forum.com/u/nishi)\
**Post date:** [May 19, 2009, 8:07am UTC](https://www.ruby-forum.com/t/how-to-use-input-control-in-loop/168287/1 "2009-05-19T08:07:06Z")

</div>

Hi everyone,

i am using a in a for loop. but not getting the  
data as loop.  
also in controller how i will fatch the data of that loop.

Here is my code.

\<% for pros in @pros%\>

  
\<%=pros.name%\>  
  

![add]()

  
  
  
0\</  
span\>  
   
\<input type=“hidden” name=“txtpros” id=“txtpros\<  
%=pros.id%\>” value=\<%=pros.id%\> \>  
   
 \<% end %\>

Javascript:------

function addpros(theCount,txtpros,txtT)  
{  
if(parseFloat(document.getElementById(theCount).value) \> 0){  
document.getElementById(theCount).value = parseFloat  
(document.getElementById(theCount).value)-1;  
/_document.getElementById(txtpros).value = parseFloat  
(document.getElementById(txtpros).value)+1;_/  
document.getElementById(theCount).innerHTML = parseFloat  
(document.getElementById(theCount).innerHTML)+1;  
document.getElementById(txtpros).innerHTML = parseFloat  
(document.getElementById(txtpros).innerHTML )+1;  
document.getElementById(txtT).value = parseFloat  
(document.getElementById(txtpros).innerHTML );  
}  
}

Here, im generating a table row by loop, which has to assign a value  
in each row by the input control.

when i inspect the element its gives.  
puts params.inspect

{“commit”=\>“Finish”, “captcha”=\>"", “rating\_overall”=\>"",  
“txtpros”=\>“1”, “txtT”=\>“1”,  
“authenticity\_token”=\>“a5e1c967a1a70ddc4382dc6c0ff2342705e5e376”,  
“action”=\>“add\_review”, “rating\_terms”=\>"", “controller”=\>“managers”,  
“rating\_performance”=\>"", “comment”=\>{“body”=\>""}, “rating\_Team”=\>"",  
“rating\_strategy”=\>""}  
here im getting single data.  
but i need to get data from all rows.

could u plz help me as soon as possible.

Thanks,

---

<div class="post-metadata">

**Author:** ![nishi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@nishi](https://www.ruby-forum.com/u/nishi)\
**Post date:** [May 19, 2009, 9:34am UTC](https://www.ruby-forum.com/t/how-to-use-input-control-in-loop/168287/2 "2009-05-19T09:34:34Z")

</div>

On May 19, 7:06 am, nishi [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi everyone,
> 
> i am using a in a for loop. but not getting the  
> data as loop.  
> also in controller how i will fatch the data of that loop.

long version: take a peak at

> **[Action View Form Helpers — Ruby on Rails Guides](https://guides.rubyonrails.org/form_helpers.html)**
>
> Action View Form HelpersForms in web applications are an essential interface for user input. However, form markup can quickly become tedious to write and maintain because of the need to handle form control naming and its numerous attributes. Rails...

or [Parametrised to the max - Space Vatican](http://www.spacevatican.org/2008/7/18/parametrised-to-the-max)

short version: Parameters need to be named appropriately (append [] to  
the parameter name) for rails to handle them as arrays (rather than  
ignoring duplicates)

Fred
