HTML calculatore

21. elokuuta 2021 | 99 näyttökertaa

<?php
# Copyright kaikkitietokoneista
# kaikkitietokoneista calculator
 ?>

 <html lang="en" dir="ltr">
   <head>
     <meta charset="utf-8">
     <title>Calculator kaikkitietokoneista</title>
     <style>
     body {
       margin: 20%;
       background-color: white;
     }

      button {
        background-color: grey;
        padding: 30px;
        border: none;
        font-size: 13;
        border-radius: 30px;
        display: inline-block;
      }

      input {
        width: 90%;
        padding: 20px;
      }

      .right {
        display: block;
        float: right;
      }
      .left {
        display: block;
        float: left;
      }
     </style>
   </head>
   <body>
     <FORM NAME="Calc">
       <center>
       <INPUT TYPE="text"   NAME="Input" Size="16">
       </center>
     </FORM>
     <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

     <div class="left">
       <button id="1" OnClick="Calc.Input.value += '1'">1</button>
       <button id="2" OnClick="Calc.Input.value += '2'">2</button>
       <button id="3" OnClick="Calc.Input.value += '3'">3</button>
       <br>
       <button id="4" OnClick="Calc.Input.value += '4'">4</button>
       <button id="5" OnClick="Calc.Input.value += '5'">5</button>
       <button id="6" OnClick="Calc.Input.value += '6'">6</button>
       <br>
       <button id="7" OnClick="Calc.Input.value += '7'">7</button>
       <button id="8" OnClick="Calc.Input.value += '8'">8</button>
       <button id="9" OnClick="Calc.Input.value += '9'">9</button>
       <br>
       <button id="0" OnClick="Calc.Input.value += '0'">0</button>
       <button id="0" OnClick="Calc.Input.value += '.'">.</button>
     </div>

     <div class="right">
       <button id="+" OnClick="Calc.Input.value += '+'">+</button>
       <br>
       <button id="-" OnClick="Calc.Input.value += '-'">-</button>
       <br>
       <button id="-" OnClick="Calc.Input.value += '*'">*</button>
       <br>
       <button id="-" OnClick="Calc.Input.value += '/'">/</button>
       <br>
       <button id="-" OnClick="Calc.Input.value = eval(Calc.Input.value)">=</button>
     </div>

   </body>
 </html>