Question : How can I paint a cell of my table when I click on the mouse ?

Hello guys

I have a table with 10 rows and 10 column.

When I click the mouse in a cell, I want to paint it of yellow,

If I click in the other cell, it must clear the cell painted and paint this new one.

How can I do this?

Thanks

Answer : How can I paint a cell of my table when I click on the mouse ?

Checkl this :

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
<html><head><script>
	function function1(e) {
		var srcElement = e.srcElement?e.srcElement:e.target;
		if( srcElement.nodeName.toLowerCase() == "td" ) {
			var cells = document.getElementsByTagName("table")[0].getElementsByTagName("td");
			for(var i=0;i<cells.length;i++) cells[i].bgColor = ""; // remove color for all cells
			if( srcElement.bgColor == "" ) {
				srcElement.bgColor = "red";
			}
			else {
				srcElement.bgColor = "";
			}
		}
	}
</script></head>
<body bgcolor="#ccffcc" text="#000000">
<table border="1" onClick="function1(event);">
	<tr>
   <td id="myTD" height="79">Cell 1 content</td>
   <td id="myTD" height="79">Cell 1 content</td>
   <td id="myTD" height="79">Cell 1 content</td>
   <td id="myTD" height="79">Cell 1 content</td>
   <td id="myTD" height="79">Cell 1 content</td>
   <td id="myTD" height="79">Cell 1 content</td>
   <td id="myTD" height="79">Cell 1 content</td>
   <td id="myTD" height="79">Cell 1 content</td>
 </tr>
</table>
</body></html>
Random Solutions  
 
programming4us programming4us