On May 19, 7:06 am, nishi <[email protected]> wrote:
> Hi everyone,
>
> i am using a <input type="text"> 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 http://guides.rubyonrails.org/form_helpers.html
or 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
> Here is my code.
>
>  <% for pros in @pros%>
>                 <tr>
>                   <td><%=pros.name%></td>
>                   <td>
>                    <p> <a href="#" onclick="addpros
> ('txt_pros_total','txtpros<%=pros.id%>','txtT<%=pros.id%>'); return
> false;"><img src="tuna.gif" alt="add" /></a></p>
>                   </td>
>                   <td>
>                  <span id="txtpros<%=pros.id%>"  class="itemCount">0</
> span>
>                  <input type="hidden" name="txtT" id="txtT<%=pros.id
> %>"  value="0"/>
>                  <input type="hidden" name="txtpros" id="txtpros<
> %=pros.id%>"  value=<%=pros.id%> ></input>
>                   </td>
>                </tr> <% 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,
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to