PivotalCandle

09-26-2009, 04:35 AM

Okay I'm having a problem getting this code to work. I've tried different things. The application is supposed to calculate the sum of two numbers the user enters and the numbers inbetween those numbers. For example 10 and 15 would make 75 (10+11+12+13+14+15) There's nothing in the parameters of the for loop as I have tried different things but I don't think I've come up with a possible solution.

<html>

<head>

<script type="text/javascript">

function calculation() {

var a = document.getElementById("oneNum").value;

var b = document.getElementById("twoNum").value;

for (a=a;a=b;a++)

{

}

document.getElementById("sum").innerHTML = "The Sum is " + totalsum.toFixed(2);

}

</script>

</head>

<body>

<h2>Sum Application</h2>

<p>This calculator calculates the sum of the numbers between two numbers inclusive that are entered by the user. <br />

For example, if the user enters 10 and 15 the application would calculate 75 (10+11+12+13+14+15).<p>

Enter first number:

<input type="text" id="oneNum">

Enter second number:

<input type="text" id="twoNum">

<br />

<input type="button" value="Calculate" onClick="calculation()">

</body>

<p id="sum"></p>

</html>

<html>

<head>

<script type="text/javascript">

function calculation() {

var a = document.getElementById("oneNum").value;

var b = document.getElementById("twoNum").value;

for (a=a;a=b;a++)

{

}

document.getElementById("sum").innerHTML = "The Sum is " + totalsum.toFixed(2);

}

</script>

</head>

<body>

<h2>Sum Application</h2>

<p>This calculator calculates the sum of the numbers between two numbers inclusive that are entered by the user. <br />

For example, if the user enters 10 and 15 the application would calculate 75 (10+11+12+13+14+15).<p>

Enter first number:

<input type="text" id="oneNum">

Enter second number:

<input type="text" id="twoNum">

<br />

<input type="button" value="Calculate" onClick="calculation()">

</body>

<p id="sum"></p>

</html>