<html>
<head>
<title>Make Table</title>
<style type="text/css">
table { background-color: #0000FF; }
td { background-color: #FFFFFF;
font-family: arial;
font-size: 16px;
padding: 12px; }
.corner { background-color: #D3D6CD; }
</style>
<script type="text/javascript">
var x = [2, 4, 6, 8, 10];
var y = [3, 5, 7, 9, 11, 13];
function mkTable(){
var row = 0; //this variable will track our rows
var htmlStr = '<table>\n<tr><td class="corner"> </td>\n';
for(var j = 0; j < x.length; j++){
htmlStr += '<td>' + x[j] + '</td>';
}
htmlStr += '</tr>\n';
//while loop builds our rows
while(row < y.length){
htmlStr += '<tr>';
//for loop builds the cells of the row
for(var i = -1; i < x.length; i++){
if(i == -1){
htmlStr += '<td>' + y[row] + '</td>';
continue;
}
htmlStr += '<td>' + (x[i] * y[row]) + '</td>';
}
htmlStr += '</tr>\n';
row++;
}
htmlStr += '</table>\n';
document.write(htmlStr);
alert(htmlStr);
}
</script>
</head>
<body>
<script type="text/javascript">
mkTable();
</script>
</body>
</html>