I’ve got some code in VBA which generates a HTML file, but to make it a bit more user-friendly, I want to include some JavaScript functions:
1. To toggle the colour on rows, so they can be marked as ‘dealt with’ (and toggled back if clicked in error).2. To hide any rows that are irrelevant, with an ‘unhide all’ button.3. To be able to search for rows containing a specific string and hide the others.
I’ve started with the first one and already I’m struggling. On my HTML file, the code is currently:
`<tr id=’ABC’ class=’unchecked’ onclick=changeColor(‘ABC’)>
In the corresponding JS file, I have the following:
`function changeColor(row) {
var thisRow = document.getElementById(row);
thisRow.classList.toggle(‘checked’);
thisRow.classList.toggle(‘unchecked’);
}
Any ideas why this isn’t working? I have a CSS file, with the following:
`tr:checked {
background-color: #0F0;
}
tr:unchecked {
background-color: #F00;
}`
I know the javascript is running on click, but it’s not actually changing anything on the page – any ideas why not?
Thanks
Chris