SerenadeSP
11-14-2005, 07:36 PM
I am having trouble with a page that I'm trying to create for a class.
Heres the code:
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Odd Sum table</title>
<style type="text/JavaScript">
document.tags.th.color = 'blue';
</style>
<script language="JavaScript">
<!-- a JavaScript program that adds the odd numbers from 1-50 -->
<!--
var sum, x;
x = 1;
sum = 0;
for ( var sum1 = x + sum; x <= 50 ) {
document.writeln( "<center>" + "<caption>" + "Sum of odd number from 1-50" + "</caption>" + "<table border=1 width=50% align="center">" );
document.writeln( "<tr><th>" + "Odd Number" + "</th></tr>" + "<tr><th>" + "sum" + "</th></tr>" + "<tr><td>" + sum1 + "</td></tr>" );
document.writeln( "</table>" + "</center>" );
}
//-->
</script>
</head><body></body>
</html>
I'm trying to make a table that will print the sum of odd integers by itself ( like 1 + 2 = 3, 2 + 3 = 5... etc.)
For some odd reason, the table will not even show! Can someone help?:confused:
Heres the code:
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Odd Sum table</title>
<style type="text/JavaScript">
document.tags.th.color = 'blue';
</style>
<script language="JavaScript">
<!-- a JavaScript program that adds the odd numbers from 1-50 -->
<!--
var sum, x;
x = 1;
sum = 0;
for ( var sum1 = x + sum; x <= 50 ) {
document.writeln( "<center>" + "<caption>" + "Sum of odd number from 1-50" + "</caption>" + "<table border=1 width=50% align="center">" );
document.writeln( "<tr><th>" + "Odd Number" + "</th></tr>" + "<tr><th>" + "sum" + "</th></tr>" + "<tr><td>" + sum1 + "</td></tr>" );
document.writeln( "</table>" + "</center>" );
}
//-->
</script>
</head><body></body>
</html>
I'm trying to make a table that will print the sum of odd integers by itself ( like 1 + 2 = 3, 2 + 3 = 5... etc.)
For some odd reason, the table will not even show! Can someone help?:confused: