Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Javascript program help
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jayshaw94




PostPosted: 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>
Sponsor
Sponsor
Sponsor
sponsor
jayshaw94




PostPosted: Fri Aug 02, 2013 2:41 pm   Post subject: RE:Javascript program help

Sorry nevermind guys figured it out
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: