Facebook
From to ja, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 214
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3. <head>
  4.         <meta charset="utf-8">
  5.         <title></title>
  6.                
  7. </head>
  8. <body>
  9.         <!--
  10.         <input type="number" id="xd"></input>
  11.         <button type="button" id="b1" onclick="be1()">pole</button>
  12.         <button id="b2" onclick="be2()">obwod</button>
  13.         <p id="ww"></p>
  14.  
  15.         <script>
  16.        
  17.                 function be1(){
  18.                         var a = parseInt(document.getElementById("xd").value);
  19.                         if(isNaN(a)) {
  20.                                 document.getElementById("ww").innerHTML = "Należy wpisać wartość liczbową";
  21.                         } else {
  22.                                 document.getElementById("ww").innerHTML = a*a;
  23.                         }
  24.                 }
  25.                
  26.                 function be2(){
  27.                         var a = parseInt(document.getElementById("xd").value);
  28.                         if(isNaN(a)) {
  29.                                 document.getElementById("ww").innerHTML = "Należy wpisać wartość liczbową";
  30.                         } else {
  31.                                 document.getElementById("ww").innerHTML = 4*a;
  32.                         }
  33.                 }
  34.        
  35.         </script>
  36.         -->
  37.        
  38.         <input type="number" id="xd"></input>
  39.         <input type="number" id="xb"></input>
  40.         <button type="button" id="b1" onclick="be1()">oblicz</button>
  41.         <p id="ww"></p>
  42.        
  43.                 <script>
  44.        
  45.                 function be1(){
  46.                         var a = parseInt(document.getElementById("xd").value);
  47.                         var b = parseInt(document.getElementById("xb").value);
  48.                         var c = 1;
  49.                         var i = 0;
  50.                         if(isNaN(a) && isNaN(b)) {
  51.                                 document.getElementById("ww").innerHTML = "Wypisz podstawę i wykładnik potęgi";
  52.                         } else if(isNaN(a)) {
  53.                                 document.getElementById("ww").innerHTML = "Wypisz podstawę potęgi";
  54.                         } else if(isNaN(b)){
  55.                                 document.getElementById("ww").innerHTML = "Wypisz wykładnik potęgi";
  56.                         } else {
  57.                                 for(i = 0; i < b; i++){
  58.                                         c *= a;
  59.                                 }
  60.                                 document.getElementById("ww").innerHTML = c;
  61.                         }
  62.                 }
  63.        
  64.         </script>
  65.        
  66. </body>
  67. </html>