Guest User

Untitled

a guest
Sep 16th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3.  
  4.     <head>
  5.         <meta charset="utf-8"/>
  6.     </head>
  7.  
  8.     <script type="text/javascript">
  9.         var napis = "";
  10.         function dopiszDoZmiennej(pierwsza, druga) {
  11.             for (i = pierwsza; i <= druga; i++) {
  12.                 napis = napis + i + " ";
  13.             }
  14.         }
  15.  
  16.         function wypisz() {
  17.             var liczba1 = document.getElementById("pole1").value;
  18.             var liczba2 = document.getElementById("pole2").value;
  19.  
  20.             if (isNaN(liczba1) || isNaN(liczba2))
  21.                 napis = "Wprowadzone dane nie sa liczbami. Popraw proszę i spróbuj ponownie.";
  22.             else if (liczba1 < liczba2)
  23.                 dopiszDoZmiennej(liczba1, liczba2);
  24.             else if (liczba1 > liczba2)
  25.                 dopiszDoZmiennej(liczba2, liczba1);
  26.             else if (liczba1 === liczba2)
  27.                 napis = liczba1;
  28.  
  29.             document.getElementById("wynik").innerHTML = napis;
  30.             napis = "";
  31.         }
  32.     </script>
  33.  
  34.     <body>
  35.  
  36.         <input type="text" id="pole1"/>
  37.         <input type="text" id="pole2"/>
  38.         <input type="submit" value="Pokaż" onclick="wypisz()"/>
  39.  
  40.         <div id="wynik"></div><br/>
  41.     </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment