Advertisement
petur_stoqnov

Untitled

Jan 27th, 2021
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function generateReport() {
  2.     let checkBoxInput = document.querySelectorAll('input');
  3.     let row = document.querySelectorAll('tbody>tr');
  4.  
  5.     let output = [];
  6.     for (let i = 0; i < row.length; i++) {
  7.         let obj = {}
  8.         if (checkBoxInput[0].checked === true) {
  9.             let employeeValue = row[i].children[0].textContent;
  10.             obj.employee = employeeValue;
  11.         }
  12.         if (checkBoxInput[1].checked === true) {
  13.             let departmentValue = row[i].children[1].textContent;
  14.             obj.deparment = departmentValue;
  15.         }
  16.         if (checkBoxInput[2].checked === true) {
  17.             let statusValue = row[i].children[2].textContent;
  18.             obj.status = statusValue;
  19.         }
  20.         if (checkBoxInput[3].checked === true) {
  21.             let hireDateValue = row[i].children[3].textContent;
  22.             obj.dateHired = hireDateValue;
  23.         }
  24.         if (checkBoxInput[4].checked === true) {
  25.             let benefitsValue = row[i].children[4].textContent;
  26.             obj.benefits = benefitsValue;
  27.         }
  28.         if (checkBoxInput[5].checked === true) {
  29.             let compensationValue = row[i].children[5].textContent;
  30.             obj.compensation = compensationValue;
  31.         }
  32.         if (checkBoxInput[6].checked === true) {
  33.             let ratingValue = row[i].children[6].textContent;
  34.             obj.rating = ratingValue;
  35.         }
  36.  
  37.         if (Object.keys(obj).length > 0) {
  38.             output.push(obj)
  39.         }
  40.     }
  41.  
  42.     document.querySelector('#output').value = JSON.stringify(output, null, 2);
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement