1
I’m trying to change the background color of cells whose values are equal to the day the user accesses the site.
The variable $dataa
keeps the dates of each name...
Table formatting (inside a php loop):
echo "
<tr>
<td id=\"linha".$l."\">".$nomes[$l]."</td>
<td class=\"dataa\">".$dataa[$l]."</td>
</tr>
";
Attempted staining:
<SCRIPT>
<?php
echo "var obj = new Array();";
for ($k=0; $k<16; $k++){
if ( $data_pro_php[$k] == '23' ) {
echo "
obj[$k] = getElementById(\"linha$k\");
obj[$k].style.backgroundColor='#FF0000';
";
}
}
?>
</SCRIPT>
I think you’re doing it the hard way. I could do it in PHP when you generate HTML, or in Javascript. So it’s a middle ground that gets confused. Can you add more PHP code? However there is an error in JS:
obj[$k] = getElementById(\"linha$k\");
missing "Document" must beobj[$k] = document.getElementById(\"linha$k\");
– Sergio
Did it work? I can put answer, it may be that others have the same problem...
– Sergio
yes. It was the lack of Document.
– HiHello
If you think it’s worth it, put.
– HiHello