Problem With Get From A Value From A Cell

Hello all,
i have an html test on university and we try to create a table with random colors when we press the button start.When we click on this button we must give a timeout interval to run this function who give random colors on the cells..this is all okay.the problem is that when we press stop button this must give the status of the last colors on the table.i mean must write 10 yellow colors 10 red .... and bla bla bla..i have the code but i can't get the value from the cell to give count + 1..look on the line i write

You Can contact with me via skype: giwrgos_0101

timi=pinakas.rows.cells[j].innerHTML;


word timi on greek is value
pinakas = array

If someone can help plz give some i try 3 days and i have the test on 27/6 and i must end it..
Thnx you all guys :)
This is the whole html + css + javascript code. :)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">;
<html xmlns="http://www.w3.org/1999/xhtml">;

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<link rel="stylesheet" type="text/css" href="http://erodios.it.teithe.gr/kourou/ExamSubmissions/Samples/exams.css"; media="screen" />
<script type="text/javascript" src="http://erodios.it.teithe.gr/kourou/ExamSubmissions/Samples/exams.js"></script>;
<script language=javascript>
var colors=new Array("aqua", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "yellow");
var on=0;
var randomnumber=0;
var r=0 ;
var y=0;

function filltable(){
var mytable=document.getElementById("mytable");
for(i=0; i<mytable.rows.length; i++){
for(j=0;j<mytable.rows[i].cells.length;j++){
var r = Math.ceil(Math.random()*15);
if (r>7){
mytable.rows[i].cells[j].style.backgroundColor=colors[r];

}else{
mytable.rows[i].cells[j].style.backgroundColor=colors[r];
 
}
}}
}
var t;
var oldcolor;
function Start(ev){
	on++;
	if(on==1){
		document.getElementById("koubi").value="Stop";
		SetTable();
	t=setInterval(function(){filltable()},100);
	}
	if(on>1){
		document.getElementById("koubi").value="Start";
		on=0;
		clearInterval(t);
		apotelesma=document.getElementById("statistika");
		pinakas=document.getElementById("mytable");
		var pinakas_stat=new Array();
		for(var e=0; e<15; e++) { <!-- i give zero stat to all cells from table who will get the whole stats of all colors -->
			pinakas_stat[e]=0;
		}
		for(var i=0; i<10; i++){ <!-- here i scan the rows from table with random colors -->
			for(j=0; j<10; j++){ <!--  here i scan the cells from table with random colors  -->
				timi=pinakas.rows[i].cells[j].innerHTML;
				for(var k=0; k<15; k++) { <!-- here i scan the cells from table who have the names of colors -->
					if(timi == colors[k]) {
						pinakas_stat[k]+=1;<!-- i count the stat for colors when i stop the button -->
					}
				}
			}				
		}
		apotelesma.innerHTML="Statistika";
		for(var a=0; a<15; a++) {
			apotelesma.innerHTML+=" ";
			apotelesma.innerHTML+=pinakas_stat[a] + " ";
			apotelesma.innerHTML+=colors[a] + " ";
		}
	}
}
function SetTable() {
	var pinakas=document.getElementById("mytable");
	var rows=10;
	var cells=10;
	var sir=0;
	var kel=0;
	metritis=0;
	pinakas.cellPadding=10;
	for(var i=0; i<10; i++){
		sir=pinakas.insertRow(pinakas.rows.length);
		for(j=0; j<10; j++){
			kel=sir.insertCell(j);
		}				
	}
	
}
</script>

</head>

<body>
<input id="koubi" name="Button1" type="button" value="Start" onclick="Start(event)"/>
<div id="statistika" style="height:50px; width:50px; margin-left:80%;"></div>
<table id="mytable" border="1">
</table>



</body>

</html>

Comments

Sign In or Register to comment.