mercredi 29 avril 2015

Check whether the check-box is checked or not using Rails 3

I have a check-box inside a form.I need if user will checked this check-box suddenly the action will execute and it will check the check-box status whether it is checked or not using Rails 3.My form is given below.

paym.html.erb:

<%= form_for :add_payment,:url => {:action => 'add_payment' },remote: true do |f| %>
<table class="table table-bordered">
        <colgroup>
            <col class="col-md-1 col-sm-1">
            <col class="col-md-1 col-sm-1">
            <col class="col-md-3 col-sm-3">
            <col class="col-md-3 col-sm-3">
            <col class="col-md-4 col-sm-4">
        </colgroup>
        <thead>
            <tr>
                <th class="text-center"><input type="checkbox"></th>
                <th class="text-center">Sl. No</th>
                <th class="text-center">Date</th>
                <th class="text-center">Receipt No.</th>
                <th class="text-center">Amount</th>
            </tr>
        </thead>
        <tbody>
            <% @result.each do |r| %>
            <tr>
                <th class="text-center"><%= check_box_tag :check_value,nil,:id => "checkbox1-1"  %></th>
                <td class="text-center"><%= r.id %></td>
                <td class="text-center"><%= r.c_date %></td>
                <td class="text-center"><%= r.Receipt_No %></td>
                <td class="text-center"><i class="fa fa-rupee"></i><%= r.v_amount %></td>
            </tr>
            <% end %>
     </tbody>
</table>
<% end %>

paym_controller.rb:

class PaymentsController < ApplicationController
def add_payment

    end
end

Here i have a table with some value .I also need when user will checked that box 1-It will check whether check box is checked or not,2-If checked then it will get all table value corresponding to that check-box.Please help me.




Aucun commentaire:

Enregistrer un commentaire