Advertisement
Guest User

dupa

a guest
Jan 17th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4.  
  5. <meta charset="utf-8">
  6.  
  7. <script>
  8.  
  9. function oblicz()
  10. {
  11. var a = document.getElementById("a").value;
  12. var b = document.getElementById("b").value;
  13.  
  14. if(isNaN(a) || isNaN(b))
  15. {
  16. alert("Podaj liczbe");
  17. return;
  18. }
  19.  
  20. if(a==0 || b==0 || a<0 || b<0)
  21. {
  22. alert("Podaj liczbe");
  23. return;
  24. }
  25.  
  26. var pole = a*b;
  27. var obwod = (2*a)+(2*b);
  28.  
  29. document.getElementById("pole").innerHTML = "Pole prostokąta= " +pole;
  30. document.getElementById("obwod").innerHTML = "Obwód prostokąta= " +obwod;
  31. }
  32.  
  33. </script>
  34.  
  35. </head>
  36.  
  37. <body>
  38.  
  39. <fieldset>
  40. <legend>Obliczenia</legend>
  41. <input type="text" id="a" placeholder="Podaj bok a"><br>
  42. <input type="text" id="b" placeholder="Podaj bok b"><br><br>
  43.  
  44. <button onclick="oblicz();">Oblicz</button>
  45.  
  46. <p id="pole"></p>
  47. <p id="obwod"></p>
  48. </fieldset>
  49.  
  50. </body>
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement