Here's my effort. I've annotated the code for ease of interpretation.
HTML Code:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="pageHead">
<!-- Page Title-->
<title>Squares and Cubes</title>
<!-- Meta Block -->
<meta content="text/html; charset=iso-8859-1" http-equiv="content-type" />
<meta content="Squares and Cubes" name="description" />
<meta content="square, cube, numbers" name="keywords" />
<meta content="all,index,follow" name="robots" />
<meta content="noodp" name="msnbot" />
<meta content="global" name="distribution" />
<!-- JavaScript Scripts-->
<script type="text/javascript">
//<[CDATA[
/*
* Function: displayTable - Outputs XHTML values to the page.
*/
function displayTable() {
/*
* Locate "tblBody" tbody element on the page.
*/
var el = document.getElementById('tblBody');
/*
* Inject XHTML into the table, using Math.pow(n,p);
*/
for (i = 0; i <= 10; i++) {
/*
* Create local variable, strXHTML, to house the XHTML to output.
*/
var strXHTML = '';
/*
* Build each table row with calculated values.
*/
strXHTML += '<tr>';
strXHTML += ' <td>' + i + '</td>';
strXHTML += ' <td>' + Math.pow(i, 2) + '</td>';
strXHTML += ' <td>' + Math.pow(i, 3) + '</td>';
strXHTML += '</tr>';
/*
* Inject temporary XHTML into the table body.
*/
el.innerHTML += strXHTML;
}
}
/*
* When the page loads, run the above code.
*/
window.addEventListener('load', displayTable, false);
//]]>
</script>
<!-- CSS Styles -->
<style type="text/css">
/*
* TABLE STYLES
*/
table, td, th
{
border: 1px solid #000000;
border-collapse: collapse;
padding: 5px;
margin: 5px;
text-align: center;
}
</style>
</head>
<body>
<div id="page">
<table>
<tbody id="tblBody">
<tr>
<th>
n
</th>
<th>
n*n
</th>
<th>
n*n*n
</th>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Bookmarks