Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.92 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.    
  5. </head>
  6. <body>
  7.  
  8. <h1>Wypisanie parzystych lub nieparzystych liczb z przedziału</h1>
  9. <label>Pierwsza liczba: <input type="text" id="a"></label></br></br>
  10.  
  11. <label>Druga liczba: <input type="text" id="b"></label></br></br>
  12.  
  13. <input type="button" value="Wypisz parzyste" onclick="parzyste()">
  14. <input type="button" value="Wypisz nieparzyste" onclick="nieparzyste()">
  15.  
  16.  
  17.  
  18. <script>
  19.  
  20. function parzyste(){
  21.     var a = document.getElementById("a").value;
  22.     var b = document.getElementById("b").value;
  23.     a=parseInt(a);
  24.     b=parseInt(b);
  25.    
  26.     if(a%2!=0) a+=1;
  27.  
  28.     while(a<=b)
  29.         {
  30.             document.write(a+"</br>");
  31.             a+=2;
  32.         }
  33.     }
  34.  
  35.  
  36. function nieparzyste(){
  37.     var a = document.getElementById("a").value;
  38.     var b = document.getElementById("b").value;
  39.     a=parseInt(a);
  40.     b=parseInt(b);
  41.    
  42.     if(a%2==0) a+=1;
  43.  
  44.     while(a<=b)
  45.         {
  46.             document.write(a+"</br>");
  47.             a+=2;
  48.         }
  49.     }
  50.  
  51. </script>
  52.  
  53. </body>
  54. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement