HI ?
I am pretty new to javascript and I Have been beating my head agianst the wall for days now.
I need help.
What I want is to have a cell so when you click on it, it switches to a color. But heres the catch I have a list of colors and every time you click the cell I would like it to switch to the next color on the list then when you at the end of the color list it repeats it’s self.
For example if I have cells 1 -4
and colors 1-5
I click on cell 1 once I should get the 1st color
I click on cell 2 I should get the second color
I click back on cell 1 I should get the third color
I don’t think this will help but heres my code:
[COLOR=darkblue] <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<script language = “JavaScript” type = “text/javascript”>
var BGC;
var COL;
function add(a)
{
var x = x+1;
}
if (x = 1){BGC=”white”; COL = “black”;}
else if (x = 2){BGC=”black”; COL = “white”;}
else if (x = 3){BGC=”yellow”; COL = “green”;}
else if (x = 4){BGC=”green”; COL = “yellow”;}
else if (x = 5){BGC=”red”; COL = “blue”;}
else if (x = 6){BGC=”blue”; COL = “red”;}
else if (x = 7){BGC=”black”; COL = “orange”;}
else if (x = 8){BGC=”white”; COL = “orange”;}
else if (x = 9){BGC=”yellow”; COL = “blue”;}
else if (x >=10){x=1;}
</script>
<head>
<title>TITLE</title>
</head>
<body>
<table>
<tr>
<td bgcolor = BGC; color = COL; onclick =”add(‘a’)”; id= “yellow” >yellow</td>
<td id = “hello” onclick=”alert(‘click’);”>hello</td>
</tr>
<tr>
<td id = “mellow” onclick =”colorchange(x);”>mellow</td>
<td id = “jello”>jello</td>
</tr>
</table>
<table border=1>
<tr><td onclick=”this.bgcolor=BGC” >A</td><td onclick=”this.bgColor=’red'”>C</td></tr>
<tr><td onclick=”this.bgColor=’red'”>B</td><td onclick=”this.bgColor=’red'”>D</td></tr>
</table>
</body>
</html>
Thanks