Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang= pl >
- <head>
- <meta charset= utf-8 >
- <title></title>
- <script>
- "use strict";
- var zp1, zp2, zbt1, ztxt1, zpole, zobw, x;
- window.onload = function (){
- ztxt1 = document.getElementById("txt1");
- zbt1 = document.getElementById("bt1");
- zp1 = document.getElementById("p1");
- zp2 = document.getElementById("p2");
- zbt1.onclick = function (){
- if((ztxt1.value == "") || (isNaN(ztxt1.value))){
- alert("wpisz liczbe w 1 polu");
- ztxt1.value = "";
- ztxt1.focus();
- return;
- }
- x = parseFloat(ztxt1.value);
- zpole = Math.round(Math.PI*x*x);
- zobw = Math.round(2*Math.PI*x);
- zp1.innerHTML = "Pole wynoci: "+zpole+"m<sup>2</sup>, a obwód: "+zobw+"m.";
- zp2.innerHTML = "Pole wynoci: "+zpole+"m<sup>2</sup>.";
- zp2.innerHTML = zp2.innerHTML+" <br>Obwód wynosi: "+zobw+"m.";
- }
- }
- </script>
- </head>
- <body>
- <p><h1>JS z e14-01-2015 pole i obwód koła</h1></p>
- Długość promienia = <input type=text id="txt1" >w metrach.<br /><br />
- <input type=button id="bt1" value="oblicz pole i obwó prostokąta" >
- <br><br>
- <p id=p1>
- <p id=p2>
- </p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement