Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>strona</title>
  6. <style>
  7. body
  8. {
  9. background-color:gray;
  10. }
  11. </style>
  12. </head>
  13.  
  14. <body>
  15. <input type="text" id="p1">
  16. <input type="text" id="p2">
  17. <input type="button" value="wyslij" onclick="licz()">
  18. <div id="wynik"></div>
  19. <script>
  20. function licz()
  21. {
  22. var x = document.getElementById("p1").value;
  23. var y = document.getElementById("p2").value;
  24.  
  25. x = parseInt(x);
  26. y = parseInt(y);
  27.  
  28. var str="";
  29.  
  30. if(x>y)
  31. {
  32. for(var i=x; i>=y; i--)
  33. {
  34. str = str+" "+i;
  35. //str+=","+i; to samo
  36. }
  37.  
  38. }
  39. else if(x<y)
  40. {
  41. for(var i=x; i<=y; i++)
  42. {
  43. str = str+" "+i;
  44. }
  45.  
  46. }
  47. else if(x==y)
  48. {
  49.  
  50. str = str+" "+x;
  51. }
  52. else if(isNaN(x)||isNaN(y))
  53. {
  54. str = "Podaj liczbe";
  55. }
  56. document.getElementById("wynik").innerHTML = str;
  57.  
  58.  
  59. }
  60. </script>
  61. </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement