how to do multiple loops and display data as shown in the picture
I have data in the form of an array and I want to loop it so that it looks like this picture
here's my script
var pf_lookup = {};
var pf_item_name = [];
var pf_item_code = [];
var pf_lot = [];
var pf_pdo_item = [];
var pf_item_process = [];
for (var itemdtl, i = 0; itemdtl = data[i++];) {
//console.log(itemdtl);
var item_name = itemdtl.ITEM_NAME;
var item_code = itemdtl.ITEM_CODE;
var greige_num = itemdtl.GREIGE_NUM;
var lot = itemdtl.LOT;
var item_process = itemdtl.ITEM_PROCESS;
if (!(item_code in pf_lookup)) {
pf_lookup[item_code] = 100;
pf_item_name.push(item_name);
pf_item_code.push(item_code);
pf_greige_num.push(greige_num);
pf_lot.push(lot);
pf_item_process.push(item_process);
}
}
$.each(pf_item_code, function (i, val) {
var itemQtyPack = 0;
var WeightPack = 0;
var WeightPackLot = '';
for (var j = 0; j < data.length; ++j) {
var pf_lookupx = {};
var pf_lotxx = [];
var item_codex = data[j]['ITEM_CODE']
var lotx = (data[j]['LOT'])
var item_name = data[j]['ITEM_NAME']
var greige_num = data[j]['GREIGE_NUM']
var netto = data[j]['NETTO']
if (pf_item_code[i] == data[j]['ITEM_CODE']) {
var lotArray = lotx.split(" ")
for (var k = 0; k < lotx.length; ++k) {
}
$.each(lotArray, function (i, val) {
for (var k = 0; k < data.length; ++k) {
if (pf_item_code[i] == data[k]['ITEM_CODE']) {
}
}
})
}
}
})
I've managed to get the item_code, but when looping lots it only shows 1 lot there should be 2 lots, and after the lot is found then looping to get the list greige_num, how ?
The second last loop condition, shouldn't it be
for (var k = 0; k < lotArray.length; ++k) { // code ...}