Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
how to do multiple loops in Javascript and display data as shown in the picture

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

enter image description here

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 ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The second last loop condition, shouldn't it be

for (var k = 0; k < lotArray.length; ++k) { // code ...}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!