Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
When i select multiple rows of a table and push a data in an array . He is create every time new array with duplicate value .. Please ! give me best solution.

My OutPut he display two array at a time
(2) [{…}, {…}]
0: {SKU: "K0012", ProductName: "Blender, Dry mill. 2 in 1 Juicer 100% Pure Copper,…tional 2 in 1 Juicer, Grinder and Chopper Machine", OrderNo: "125013853543546"}
1: {SKU: "C0040-2", ProductName: "Pack Of 12 Brushes/ Quality Fabrics Makeup Brush Set / Pack of 12 Brushes", OrderNo: "125592566258677"}
{SKU: "K0012", ProductName: "Blender, Dry mill. 2 in 1 Juicer 100% Pure Copper,…tional 2 in 1 Juicer, Grinder and Chopper Machine", OrderNo: "125013853543546"}

(2) [{…}, {…}]
0: {SKU: "K0012", ProductName: "Blender, Dry mill. 2 in 1 Juicer 100% Pure Copper,…tional 2 in 1 Juicer, Grinder and Chopper Machine", OrderNo: "125013853543546"}
1: {SKU: "C0040-2", ProductName: "Pack Of 12 Brushes/ Quality Fabrics Makeup Brush Set / Pack of 12 Brushes", OrderNo: "125592566258677"}
{SKU: "K0012", ProductName: "Blender, Dry mill. 2 in 1 Juicer 100% Pure Copper,…tional 2 in 1 Juicer, Grinder and Chopper Machine", OrderNo: "125013853543546"}




And i want only one Array not multiple with unqiue values

What I have tried:

 function ChangeFun() {
$("input[name='case[]']").change(function () {
            var values = new Array();
            $.each($("input[name='case[]']:checked"), function () { 
                var data = $(this).parents('tr:eq(0)');
                values.push({
                    'SKU': $(data).find('td:eq(2)').text(),
                    'ProductName': $(data).find('td:eq(3)').text(),
                    'OrderNo': $(data).find('td:eq(4)').text()
                });
            });
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900