<NEW!>I have managed to make some progress and need help with only 1 issue!
This part solved and displays updated text in column/row "State" every 500 ms.
Can someone help me please.
I would like to change the colour & cell background depending on the text in state column.
Ie Relay 1 has 2 states on/off.
When its ON I would like to change cell "State" background to red and text colour to white.
When its OFF I would like to change cell "State" background to green and text colour to black.
The page is loaded to SD and called by program and all works but don't know where to begin with HTML
But I cannot get it to work in column "state"
It works in the Signal column if I define the "Error" signal and choose MediumSeaGreen.
next is looking for error 1 in Green and it doesn't find it!
I will upload the circuit diagram and whole code once I get time to.
This issue is simply a HTML one.
If I add this line to code :- document.getElementById("val0").innerHTML = "Error 1";
it does turn the cell Green but obviously it stays Green !
It's as if the value in
<td><b><span id="val3">...</b></span>
is somehow different to "Error 1" , LightBlue for "..." also works.
I just don't get it!
<script>
var t = document.getElementById('info');
document.getElementById("val3").innerHTML = "Error 1";
if(t) {
Array.from(t.rows).forEach((td, rowIdx) => {
Array.from(td.cells).forEach((cell, cellIdx) => {
if (cell.innerText == 'Relay 1') {cell.style.backgroundColor = 'Red';}
else if (cell.innerText == "Error") {cell.style.backgroundColor = 'MediumSeaGreen';}
else if (cell.innerText == "Error 1") {cell.style.backgroundColor = 'Green';}
else if (cell.innerText == '...') {cell.style.backgroundColor = 'LightBlue';}
});
});
}
</script>
So how will that work?
data in "State" column/row is active and updated every 500 ms.
I need the cell column/row colours to change dependent on the value of the data displayed in the "state" column/row.
Please see code above.
Thanks for you suggestion though.
Hello @bms_007 - I've been away from table-making js and css for twenty years, but my guess on this issue is; trying to change the background of a pre-defined cell (or row) might better be solved by pre-defining a "bgred" cell/row and "bggrn" cell/row, then IF a state change becomes 0, use the "bgred" cell/row ELSE use "bggrn" cell/row. I think your code is coloring the cell as you intend, but it then gets overlayed by a higher priority.
Thanks @XFPD could you please elaborate a little, This is my first venture into HXML/XML/CSS and I am no expert. I've spent several days on this issue and find the language counter intuitive.
A example would help tremendously.
Thanks in advance.