bebo231312312321

Untitled

Feb 2nd, 2024
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function generateReport() {
  2.  
  3.     const headerBoxes = Array.from(document.querySelectorAll('thead tr th input'));
  4.     const headerBoxesL = headerBoxes.length;
  5.     const infoTable = Array.from(document.querySelectorAll('tbody tr'));
  6.     const infoTableL = infoTable.length;
  7.     const output = document.getElementById('output');
  8.  
  9.     const result = [];
  10.  
  11.     for (let i = 0; i < infoTableL; i++) {
  12.  
  13.         const report = {};
  14.  
  15.         for (let j = 0; j < headerBoxesL; j++) {
  16.  
  17.             if (headerBoxes[j].checked) {
  18.                 report[headerBoxes[j].name] = infoTable[i].children[j].textContent;
  19.             }
  20.         }
  21.         result.push(report);
  22.     }
  23.     output.textContent = JSON.stringify(result);
  24. }
Add Comment
Please, Sign In to add comment