Forum Moderators: open
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title></title>
<style type="text/css">
#mytable {
border:1px solid #999;
margin:auto;
}
#mytable td {
width:30px;
height:30px;
border:1px solid #666;
text-align:center;
}
.green {
background-color:#f00;
}
.red {
background-color:#0f0;
}
</style>
<script type="text/javascript">
function setTdBackground(){
cells=document.getElementById('mytable').getElementsByTagName('td');
for(c=0;c<cells.length;c++) {
if(cells[c].firstChild.nodeValue==1 ){
cells[c].className='green';
}
else {
if(cells[c].firstChild.nodeValue==0){
cells[c].className='red';
cells[c].firstChild.nodeValue='';
}
}
}
}
if(window.addEventListener){
window.addEventListener('load',setTdBackground,false);
}
else {
if(window.attachEvent){
window.attachEvent('onload',setTdBackground);
}
}
</script>
</head>
<body>
<table id="mytable"><tr>
<td>0</td><td>1</td><td>1</td><td>0</td>
</tr><tr>
<td>1</td><td>0</td><td>1</td><td>0</td>
</tr><tr>
<td>1</td><td>0</td><td>0</td><td>0</td>
</tr><tr>
<td>0</td><td>1</td><td>0</td><td>1</td>
</tr></table>
</body>
</html>
No problem, you're very welcome. ;)