SHARE
TWEET

Untitled

a guest Jan 19th, 2020 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <input type="text" id="wartosc" value="">
  5. <input type="submit" onclick="oceny()"/>
  6. <p>Oceny: <div id="oceny"></div>
  7. <p>Srednia: <div id="srednia"></div>
  8. <script>
  9.     var a =[];
  10.     function oceny(){
  11.         var ocena = document.getElementById("wartosc").value;
  12.         var error = 0;
  13.         if(ocena>6){
  14.             alert("Ocena nie moze byc wieksza niz 6")
  15.             error=1;
  16.         }
  17.         if(ocena<1){
  18.             alert("Ocena nie moze byc mniejsza niz 1")
  19.             error=1;
  20.         }
  21.         if(error==0){
  22.             document.getElementById("oceny").innerHTML += "<b>"+ocena+" </b>"
  23.             a.push(parseInt(ocena))
  24.             var srednia = 0;
  25.             for(var ile=0; ile<a.length; ile++){
  26.                 srednia = srednia + a[ile];
  27.             }
  28.             var IleLiczb = a.length;
  29.             srednia = srednia / IleLiczb;
  30.             document.getElementById("srednia").innerHTML = srednia;
  31.         }
  32.     }
  33. </script>
  34. </body>
  35. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top