Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function generateReport() {
- let checkBoxInput = document.querySelectorAll('input');
- let row = document.querySelectorAll('tbody>tr');
- let output = [];
- for (let i = 0; i < row.length; i++) {
- let obj = {}
- if (checkBoxInput[0].checked === true) {
- let employeeValue = row[i].children[0].textContent;
- obj.employee = employeeValue;
- }
- if (checkBoxInput[1].checked === true) {
- let departmentValue = row[i].children[1].textContent;
- obj.deparment = departmentValue;
- }
- if (checkBoxInput[2].checked === true) {
- let statusValue = row[i].children[2].textContent;
- obj.status = statusValue;
- }
- if (checkBoxInput[3].checked === true) {
- let hireDateValue = row[i].children[3].textContent;
- obj.dateHired = hireDateValue;
- }
- if (checkBoxInput[4].checked === true) {
- let benefitsValue = row[i].children[4].textContent;
- obj.benefits = benefitsValue;
- }
- if (checkBoxInput[5].checked === true) {
- let compensationValue = row[i].children[5].textContent;
- obj.compensation = compensationValue;
- }
- if (checkBoxInput[6].checked === true) {
- let ratingValue = row[i].children[6].textContent;
- obj.rating = ratingValue;
- }
- if (Object.keys(obj).length > 0) {
- output.push(obj)
- }
- }
- document.querySelector('#output').value = JSON.stringify(output, null, 2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement