Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 22nd, 2013, 10:46 PM   #1
potosauros
Newbie
 
Join Date: Jun 2013
Posts: 2
Rep Power: 0 potosauros is on a distinguished road
Unhappy 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[i].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>

Last edited by Ancient Dragon; Jun 23rd, 2013 at 10:36 AM. Reason: add code tags
potosauros is offline   Reply With Quote
Old Jun 24th, 2013, 3:01 AM   #2
potosauros
Newbie
 
Join Date: Jun 2013
Posts: 2
Rep Power: 0 potosauros is on a distinguished road
Re: Problem With Get From A Value From A Cell

one help lol :/
potosauros is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MFC CListCtrl: Change cell size on the fly from within a custom draw handler kurt C++ 0 Jan 9th, 2012 4:52 PM
Serious RichTextBox problem most hacker C# 0 Feb 27th, 2010 4:23 AM
How to develop problem analysis skills to enable one to decipher a given problem before coding in C++ Man G C++ 7 Apr 16th, 2009 4:49 AM
Problem solving ReggaetonKing Software Design and Algorithms 7 Jan 4th, 2008 1:49 PM
check cell one below - if found add to cell above crmpicco Visual Basic 0 May 9th, 2005 6:32 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:39 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC