I have created a table using data from a parsed CSV file. The table consists of two columns - one for extracted values and the other for dropdown selection. However, I am struggling to extract the values selected in the dropdown fields. Can anyone assist me with this?
In my HTML code, the table structure looks like this:
function extractTable() {
var csvTable = document.querySelector("#csv_table");
var newTableObj = [];
var tableRows = [].reduce.call(csvTable.rows, function(res, row) {
res[row.cells[0].textContent] = row.cells[1].textContent;
return res;
}, {});
delete tableRows['Column value']; // Removes the header row
// Create an object
newTableObj.push(tableRows);
console.log(newTableObj);
// Create a JSON
let jsonTable = JSON.stringify(tableRows, null, 2);
console.log(jsonTable);
};
If you'd like to view an example on CodePen, here is the link: https://codepen.io/AllenT871/pen/XoazJz?editors=1011#
Any assistance or feedback would be greatly appreciated.