Facebook
From ASDFFF#####, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 199
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7.     <title>JS funkcje</title>
  8. </head>
  9. <body>
  10.         Podaj promien kola <input id="input1" type="text" />
  11.         <button onclick="przetwarzanie();"> Oblicz pole i obwod kola </button>
  12.        
  13. <p id="paragraf1"> </p>
  14. <p id="paragraf2"> </p>
  15. <script>
  16.  
  17. function poleK(r) {
  18.  
  19. return Math.PI * r * r;
  20. }
  21. function obwodK(r) {
  22.     return 2 * Math.PI * r;
  23. }
  24. function przetwarzanie() {
  25.     var input1 = document.getElementById("input1");
  26. var p1 = document.getElementById("paragraf1");
  27. var p2 = document.getElementById("paragraf2");
  28. var r = Number(input1.value);
  29. var pK = poleK(r);
  30. var oK = obwodK(r);
  31. p1.innerHTML = "Pole = " + pK;
  32. p2.innerHTML = "Obwod = " + oK;
  33. }
  34. </script>
  35. </body>
  36. </html>
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. <!DOCTYPE html>
  65. <html lang="en">
  66. <head>
  67.     <meta charset="UTF-8">
  68.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  69.     <meta http-equiv="X-UA-Compatible" content="ie=edge">
  70.     <title>Js funkcje</title>
  71. </head>
  72. <body>
  73.     <form>
  74.         Podaj pojemność baku paliwa kutra rybackiego w litrach
  75.         <input type="text" id="input1"><br>
  76.         Podaj odległość w milach morskich
  77.         <input type="text" id="input2"><br>
  78.         <button onclick="oblicz();return false;">Oblicz spalanie średnie</button>
  79.         <p id="paragraf1"></p>
  80.     </form>
  81.     <script>
  82.         function mileNaKilometry(mile_morskie)
  83.         {
  84.             return mile_morskie * 1.852;
  85.         }
  86.         function spalanieSrednie(pojemnosc,kilometry)
  87.         {
  88.             return pojemnosc*100/kilometry;
  89.         }
  90.         function oblicz()
  91.         {
  92.             var input1=document.getElementById("input1");
  93.             var input2=document.getElementById("input2");
  94.             var p1=document.getElementById("paragraf1");
  95.             var pojemnosc=Number(input1.value);
  96.             var mile_m=Number(input2.value);
  97.             var km=mileNaKilometry(mile_m);
  98.             var spalanie=spalanieSrednie(pojemnosc,km);
  99.             p1.innerHTML="Spalanie średnie: "+spalanie.toFixed(2);
  100.         }
  101.     </script>
  102. </body>
  103. </html>
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117. <!DOCTYPE html>
  118. <html lang="en">
  119. <head>
  120.     <meta charset="UTF-8">
  121.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  122.     <meta http-equiv="X-UA-Compatible" content="ie=edge">
  123.     <title>Js funkcje</title>
  124. </head>
  125. <body>
  126.     <form>
  127.       Podj odległość w metrach: <br>
  128.       <input  id="input1" type="text" value="1000"> <br> <br>
  129.       <button onclick="przelicz();return false;">Przelicz na inne jednostki</button>
  130.  
  131.     </form>
  132.     <p id="paragraf1"></p>
  133.     <p id="paragraf2"></p>
  134.     <p id="paragraf3"></p>
  135.     <script src="j_odleglosci.js"></script>
  136.     <script>
  137. function przelicz(){
  138.     var input1 = document.getElementById("input1");
  139. var p1 = document.getElementById("paragraf1");
  140. var p2 = document.getElementById("paragraf2");
  141. var p3 = document.getElementById("paragraf3");
  142.  
  143. var metry = Number(input1.value);
  144. p1.innerHTML ="Mile ang: " + metryNaMileang(metry).toFixed(4);
  145. p2.innerHTML ="Stopy: " + metryNaStopy(metry).toFixed(0);
  146. p3.innerHTML ="Jardy: " + metryNaJardy(metry).toFixed(2);
  147. }
  148.  
  149.  
  150. </script>
  151.  
  152. </body>
  153. </html>