Good morning everyone! Gentlemen, it is as follows: I have a table where I load information from the database, and display it on that table. The table is ready and loading the data right. What I need is to change the color of the backgroud of one of these cells taking into account a condition, which is as follows: If the information I have is equal to 'S' it will change the text to 'Hit' and the backgroud to blue for example, if it is not equal, change the text to 'Error' and backgroud to red.
I have tried to do this as follows:
function status(){
var status = document.getElementById("idcampostatus").value;
if(status == "S"){
//status.value = "Acerto";
status.style.backgroundColor="#428bca"
}else{
//status = "Erro";
status.style.backgroundColor="#d9534f";
}
}
But I do not know if this function is really right, nor how to call table_ (cell) _, because it is not a clickable element, and I do not know if onLoand()
works on a table.
Thanks in advance for all your help!