So i make javascript execute the following script:
const tableBody = document.querySelector('tbody'); // Assuming 'tbody' is the direct parent of rows
// Check if the table body is found
if (tableBody) {
// Get all child rows
const rows = tableBody.querySelectorAll('tr');
// Initialize a counter to track names
let nameCount = 0;
// Loop through each row
for (let i = 0; i < rows.length; i++) {
const row = rows[i];
// Get the second child cell (assuming names are in the second column)
const nameCell = row.querySelector(':nth-child(2)');
// Check if the cell exists and extract text
if (nameCell) {
const name = nameCell.textContent.trim();
console.log(`Name ${nameCount + 1}: ${name}`); // Process or display the extracted name
nameCount++; // Increment the counter
}
}
console.log(Total Names Found: ${nameCount}); // Display the total number of names
} else {
console.error('Table body not found!');
}
is it possible, and how can i like parse nameCount and name to log from the script which was executed