silkyheart 0 Newbie Poster

How can i randomize the color of each cell using Math.ceil(Math.random())?

this is the code:

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

<html>
<head>
	<style type="text/css">
		body {
			margin-left: 20%;
			margin-right: 20%;
		}
		h1 {
			font-family: jokerman;
			text-align: center;
		}
		td {
			border-style: outset;
			border-width: 5px;
			border-color: gray;
			font-family: courier new;
		}
		td:hover {
			border-style: inset;
			color:red;
		}
	</style>
</head>
<body>
	<h1>Multiplication Table</h1>
	<br /><br /><br />
	<script type="text/javascript">
		mess = "Please enter the number of rows <1-10>."
		do {
			x = window.prompt(mess);
			x = parseInt(x);
			mess = mess + "\nInvalid entry. Please try again."
		} while (x<1 || x>10)
		
		mess2 = "Please enter the number of columns <1-10>."
		do {
			y = window.prompt(mess2);
			y = parseInt(y);
			mess2 = mess2 + "\nInvalid entry. Please try again."
		} while (y<1 || y>10)
		
		
		document.write("<table>");
		for (i=1; i<=x; i++) {	
			document.write("<tr>");
			for (j=1; j<=y; j++) {
				document.write("<td>", i, "*", j, "</td>");
			}
			document.write("</tr>");
		}
		document.write("</table>");
	</script>
</body>
</html>

thanks to anyone who helps... :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.