Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="pl">
- <head>
- <meta charset="UTF-8">
- <title>strona</title>
- <style>
- body
- {
- background-color:gray;
- }
- </style>
- </head>
- <body>
- <input type="text" id="p1">
- <input type="text" id="p2">
- <input type="button" value="wyslij" onclick="licz()">
- <div id="wynik"></div>
- <script>
- function licz()
- {
- var x = document.getElementById("p1").value;
- var y = document.getElementById("p2").value;
- x = parseInt(x);
- y = parseInt(y);
- var str="";
- if(x>y)
- {
- for(var i=x; i>=y; i--)
- {
- str = str+" "+i;
- //str+=","+i; to samo
- }
- }
- else if(x<y)
- {
- for(var i=x; i<=y; i++)
- {
- str = str+" "+i;
- }
- }
- else if(x==y)
- {
- str = str+" "+x;
- }
- else if(isNaN(x)||isNaN(y))
- {
- str = "Podaj liczbe";
- }
- document.getElementById("wynik").innerHTML = str;
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement