heather143
Programmer
Hi, I am very new to Javascript and am having a problem writing this program, so I was wondering if one of you experts could help me. This is the problem I am having. Its probably simple to you guys.
I am trying to do this :
when the "Start" button is clicked a random cell changes its background color to red for 350ms, then back to white, then another cell becomes red, then to a different cell, every 350ms.
It is supposed to be in a 3 x 3 table.
I am trying to get it to work by applying it to the last program i wrote wich is this one:
HTML>
<HEAD>
<TITLE> </TITLE>
<SCRIPT LANGUAGE = "JavaScript">
function clicked(){
if (event.srcElement.style.backgroundColor == "red")
event.srcElement.style.backgroundColor = "white";
else
event.srcElement.style.backgroundColor = "red";
}
</SCRIPT>
</HEAD>
<BODY>
<CENTER>
<TABLE BORDER= "1" HEIGHT= "50%" WIDTH= "50%">
<TR>
<TD ONCLICK="clicked()"> </TD>
<TD ONCLICK="clicked()"> </TD>
<TD ONCLICK="clicked()"> </TD>
</TR>
<TR>
<TD ONCLICK="clicked()"> </TD>
<TD ONCLICK="clicked()"> </TD>
<TD ONCLICK="clicked()"> </TD>
</TR>
<TR>
<TD ONCLICK="clicked()"> </TD>
<TD ONCLICK="clicked()"> </TD>
<TD ONCLICK="clicked()"> </TD>
</TR>
</TABLE>
<INPUT TYPE = "BUTTON" VALUE = "CLICK TO START" ONCLICK = "START()">
</CENTER>
</BODY>
</HTML>
Any help would be greatly appreciated.
Thank you