Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta charset="utf-8">
- <script>
- function oblicz()
- {
- var a = document.getElementById("a").value;
- var b = document.getElementById("b").value;
- if(isNaN(a) || isNaN(b))
- {
- alert("Podaj liczbe");
- return;
- }
- if(a==0 || b==0 || a<0 || b<0)
- {
- alert("Podaj liczbe");
- return;
- }
- var pole = a*b;
- var obwod = (2*a)+(2*b);
- document.getElementById("pole").innerHTML = "Pole prostokąta= " +pole;
- document.getElementById("obwod").innerHTML = "Obwód prostokąta= " +obwod;
- }
- </script>
- </head>
- <body>
- <fieldset>
- <legend>Obliczenia</legend>
- <input type="text" id="a" placeholder="Podaj bok a"><br>
- <input type="text" id="b" placeholder="Podaj bok b"><br><br>
- <button onclick="oblicz();">Oblicz</button>
- <p id="pole"></p>
- <p id="obwod"></p>
- </fieldset>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement