0

这是我的桌子:

index.html.erb:



  <center><table border="1" cellspacing="0" cellpadding="10" id="c"></center>
    <h3><center>List Of Products</h3></center>

    <tr>
    <th>S.No</th>
    <th>Products</th>
    <th>Availble Quantity</th>
    <th>Price(each per kg/qua)</th>
    <th>Quantity Requried<br>(enter required qua as per kg/qua)</br></th>
    </tr >
    <% @product.each do |product| %> 

    <tr>
    <td><center><%= product.id %></center></td>
    <td><center><%= check_box_tag "name" %> <%= product.name %></center></td>
    <td><center><%=product.quantity %></center></td>
    <td><center><%= product.price %></center></td>
    <td><center><input type= "text" style="width:50px;"></center></td>
    </tr>
    <% end %>  
    </table><br><br>
    <%= link_to "ADD",checkout_index_path, class: "btn btn-small btn-primary" %>

我的问题是,如果我选择任何复选框,它应该在下一页显示所选字段(即:index.html.erb/checkout)

我的 index.html.erb/checkout 页面:

 <p id="notice"><%= notice %></p>
    <h5>Slected products are:</h5>
    <%= link_to 'Continue Online Shopping', products_path %>

例如,如果我选择项目 1 并单击添加按钮,它应该在结帐页面中显示所选项目。帮我!!!!!

所选项目应显示在此 index.html.erb/checkout 页面中

4

1 回答 1

0

您必须将表格放在表格中。就像是:

<%= form_tag :form_products, checkout_index_path do |f| %>

你应该被定义为:<%= check_box_tag "name[#{product.id}]" %>

然后在您的结帐操作中,您将获得所有参数: params['name'][i] == '1' 其中 i 是产品 ID

于 2013-07-10T08:05:23.093 回答