<script type="text/javascript">
function setColor(a) {
if (this.a && this.a != a) this.a.style.background = "white";
a.style.background = "green";
this.a = a
}
function setColor2(a) {
a.style.background = "#39F"
}
function setColor3(a) {
a.style.background = a != this.a ? "white" : "green"
};
var n = 3;
document.write("<table border='1' style='border-collapse:collapse; width:400px; height:400px;'>");
for (var tr = 1; tr <= n; tr++) {
document.write("<tr>");
for (var td = 1; td <= n; td++) {
document.write("<td align='center' onmouseout='setColor3(this)' onmouseover='setColor2(this)' valign='middle' onclick='setColor(this)' id='tdcolor'>A</td>")};
document.write("</tr>")
}
document.write("</table>");
</script>