Computer Science Canada

Javascript program help

Author:  jayshaw94 [ Thu Aug 01, 2013 9:50 pm ]
Post subject:  Javascript program help

Hello guys. I'm in need of some help. I'm stressing out here. Teacher asked us to;

Write a program with the help of JavaScript which takes a number as input and displays all numbers from 1 to the number entered. For example, if the number entered is 5, the output should be:

1
2
3
4
5


I've been trying to use this somehow; but couldn't figure it out

<html>
<body>
<p>Click the button to calculate x.</p>
<button onclick="myFunction()">Try it</button>
<br/>
<br/>Enter first number:
<input type="text" id="txt1" name="text1">Enter second number:
<input type="text" id="txt2" name="text2">
<p id="demo"></p>
<script>
function myFunction() {
var y = document.getElementById("txt1").value;
var z = document.getElementById("txt2").value;
var x = y + z;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>

Author:  jayshaw94 [ Fri Aug 02, 2013 2:41 pm ]
Post subject:  RE:Javascript program help

Sorry nevermind guys figured it out


: