Advertisement
Marin171

generateReport

Jun 14th, 2023
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. function generateReport() {
  2. const outputElement = document.querySelector('#output');
  3. const result = [];
  4. const checks = Array.from(document.querySelectorAll('thead tr th input'));
  5. const trs = Array.from(document.querySelectorAll('tbody tr'));
  6.  
  7. trs.forEach( row => {
  8. const current = {};
  9. Array.from(row.querySelectorAll('td')).forEach((x, i) => {
  10. if(checks[i].checked) {
  11. current[checks[i].name] = x.textContent
  12. }
  13. })
  14. result.push(current)
  15. })
  16. outputElement.value = JSON.stringify(result)
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement