Advertisement
An0n0ym0usHacker

Html,CSS,Javascript Calculator

Nov 9th, 2019
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 4.05 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <script>
  5.             function insert(num){
  6.                 document.form.textview.value = document.form.textview.value + num;
  7.             }
  8.  
  9.             function equal(){
  10.                 var exp = document.form.textview.value;
  11.                 if (exp){
  12.                     document.form.textview.value = eval(exp);
  13.                 }
  14.             }
  15.  
  16.             function clean(){
  17.                 document.form.textview.value = " ";
  18.             }
  19.  
  20.             function back(){
  21.                 var exp = document.form.textview.value;
  22.                 document.form.textview.value = exp.substring(0,exp.length-1);
  23.             }
  24.         </script>
  25.  
  26.         <style>
  27.             .main{
  28.                 position: absolute;
  29.                 top: 50%;
  30.                 left: 50%;
  31.                 transform: translateX(-50%) translateY(-50%);
  32.             }
  33.  
  34.             *{
  35.                 margin: 1px;
  36.                 padding: 1px;
  37.             }
  38.  
  39.             .button{
  40.                 cursor: pointer;
  41.                 width: 50px;
  42.                 height: 50px;
  43.                 font-size: 25;
  44.                 margin: 2;
  45.             }
  46.  
  47.             .textview{
  48.                 margin: 5px;
  49.                 width: 208px;
  50.                 height: 20px;
  51.                 font-size: 25;
  52.                 padding: 5px;
  53.             }
  54.  
  55.             .background{
  56.                 background-color: red;
  57.                 height: 100%;
  58.             }
  59.         </style>
  60.  
  61.         <title> Simple Calculator </title>
  62.     </head>
  63.  
  64.     <body>
  65.         <div class ="background"> </div>
  66.             <div class ="main">
  67.                 <form name="form">
  68.                     <input class="textview" name="textview">
  69.                 </form>
  70.                 <form>
  71.                 <table>
  72.                     <tr>
  73.                         <td> <input class ="button" type="button" value="CE" onclick="clean()" > </td>
  74.                         <td> <input class ="button" type="button" value="←" onclick="back()"> </td>
  75.                         <td> <input class ="button" type="button" value="/" onclick="insert('/')"> </td>
  76.                         <td> <input class="button" type="button" value="x" onclick="insert('*')"> </td>
  77.                     </tr>
  78.                     <tr>
  79.                         <td> <input class ="button" type="button" value="7" onclick="insert(7)"> </td>
  80.                         <td> <input class ="button" type="button" value="8" onclick="insert(8)"> </td>
  81.                         <td> <input class ="button" type="button" value="9" onclick="insert(9)"> </td>
  82.                         <td> <input class ="button" type="button" value="+" onclick="insert('+')"> </td>
  83.                     </tr>
  84.                     <tr>
  85.                         <td> <input class ="button" type="button" value="6" onclick="insert(6)"> </td>
  86.                         <td> <input class ="button" type="button" value="5" onclick="insert(5)"> </td>
  87.                         <td> <input class ="button" type="button" value="4" onclick="insert(4)"> </td>
  88.                         <td> <input class ="button" type="button" value="-" onclick="insert('-')"> </td>
  89.                     </tr>
  90.                     <tr>
  91.                         <td> <input class ="button" type="button" value="1" onclick="insert(1)"> </td>
  92.                         <td> <input class ="button" type="button" value="2" onclick="insert(2)"> </td>
  93.                         <td> <input class ="button" type="button" value="3" onclick="insert(3)"> </td>
  94.                         <td rowspan="2"> <input class ="button" type="button" value="=" style=height:104px onclick="equal()"> </td>
  95.                     </tr>
  96.                     <tr>
  97.                         <td colspan="2"> <input class ="button" type="button" value="0" style=width:104px onclick=insert(0)> </td>
  98.                         <td> <input class ="button" type="button" value="." onclick="insert('.')"> </td>
  99.                     </tr>
  100.                 </table>
  101.             </form>
  102.           </div>
  103.         </body>
  104.    
  105. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement