samedi 3 juin 2017

Remove the specific element from array with checkbox in jquery table

I'm working on project here i'm facing issue, i have created jquery table and on checkbox checked get all the values of specific row and push it into array now i want to remove each row record from array when i unchecked that row, i have written some script for remove but it doesn't work properly. And also tell me that is there any easy way to get data of specific row with checkbox in jqury table.

Script

$('#view input[type=checkbox]').click(function () {                                             
                            var row = $(this).closest('tr');
                            var id = row.find('td:eq(0)').text();
                            var fname =   row.find('td:eq(1)').text();
                            var sname = row.find('td:eq(2)').text();
                            var cname = row.find('td:eq(3)').text();
                            var amount = row.find('td:eq(4)').text();
                            var paid = row.find($('.paid')).val();
                            var discount = row.find($('.Discount')).val();
                            var netAmount = row.find($('.NetAmount')).val();
                            
                            if ($(this).is(":checked")) {
                                info.push({                               
                                Fee_Id: id,
                                FeeHeadName: fname,
                                sname: sname,
                                cname: cname,
                                Amount: amount,
                                Paid: paid,
                                Discount: discount,
                                NetAmount: netAmount
                                });                            
                            console.log(info);
                          
                        }
                        else {
                               
                                if ($(this).not(":checked")) {
                                var index = info.indexOf($(this).val());
                                info.splice(index, 1);
                                console.log(info);
                            }
                        }

                    });
<script src="http://ift.tt/1oMJErh"></script>



Aucun commentaire:

Enregistrer un commentaire