Javascript-Session 2-Multiplication Table 1

A multiplication table where the number of rows and columns are set by the variables: rowNum and colNum. A link to the table is here.

<html>
<body>

<script language=”JavaScript”>

document.write(’<table border=0>’);

var rowNum =    20
var colNum =    10

//—creates index(red) row ‘X’ through number set in “var colNum”—

document.write(’<tr style=color:red>’);
document.write(’<td>’+'X’+'</td>’);
for (row1=1; row1<=colNum; row1++)
{
document.write(’<td>’+row1+’</td>’);
}
document.write(’</tr>’);

//—

var col1=1

for (row=1; row<=rowNum; row++)
{
document.write(’<tr>’);
//—creates index(red) column, number of rows determined by “var rowNum”—
document.write(’<td style=color:red>’+col1+++’</td>’);
//—
for (col=1; col<=colNum; col++)
document.write(’<td>’+col*row+’</td>’);
document.write(’</tr>’);
}
document.write(’</table>’);
</script>
</table>
</body>
</html>







Leave a Reply

You must be logged in to post a comment.