Click to See Complete Forum and Search --> : age


per
12-11-2003, 07:46 PM
Hi there,

I was wanting to achieve this:

Using "For loops", write a JavaScript routine within an html document that creates a table that has 25 rows and 25 columns with a border of 3 pixels.

In each table element, insert the element's coordinates "x,y" where x is the number of rows across and y is the number of rows down

thanks for any help

per

Pittimann
12-12-2003, 04:39 AM
Hi!

One small sample code (play with the css, if it needs adjustment):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<style type="text/css">
.myTable{
font-family: Verdana, Arial;
font-size: 9px;
text-align: center;
}
</style>
</head>
<body>
Your text above the table<br>
<script language="JavaScript" type="text/javascript">
<!--
var tableString='<table border=3>';
for (var i = 1; i < 26; i++) {
tableString += '<tr>'
for (var j = 1; j < 26; j++) {
tableString += '<td Class="myTable">' + j + ', '+ i;
}
tableString += '</tr>';
}
tableString += '</table>';
document.write(tableString);
//-->
</script>
Your text below the table
</body>
</html>

Cheers - Pit