Denis_Hristov

Calculator

Jun 24th, 2021 (edited)
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.44 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Calculator</title>
  6.     <link rel="stylesheet" href="css/CalcStyle.css">
  7. </head>
  8. <body>
  9.    
  10.     <table border ="1">
  11.        <th colspan="4">Calculator</th>
  12.        <tr>
  13.           <td colspan="3"><input type="text" id="result"/></td>
  14.           <td><input type="button" value="c" onclick="clr()"/> </td>
  15.        </tr>
  16.        <tr>
  17.           <td><input type="button" value="7" onclick="dis('7')"/> </td>
  18.           <td><input type="button" value="8" onclick="dis('8')"/> </td>
  19.           <td><input type="button" value="9" onclick="dis('9')"/> </td>
  20.           <td><input type="button" value="/" onclick="dis('/')" class="func"/> </td>
  21.        </tr>
  22.        <tr>
  23.           <td><input type="button" value="4" onclick="dis('4')"/> </td>
  24.           <td><input type="button" value="5" onclick="dis('5')"/> </td>
  25.           <td><input type="button" value="6" onclick="dis('6')"/> </td>
  26.           <td><input type="button" value="-" onclick="dis('-')" class="func"/> </td>
  27.        </tr>
  28.        <tr>
  29.           <td><input type="button" value="1" onclick="dis('1')"/> </td>
  30.           <td><input type="button" value="2" onclick="dis('2')"/> </td>
  31.           <td><input type="button" value="3" onclick="dis('3')"/> </td>
  32.           <td><input type="button" value="+" onclick="dis('+')" class="func"/> </td>
  33.        </tr>
  34.        <tr>
  35.           <td><input type="button" value="." onclick="dis('.')" class="func"/> </td>
  36.           <td><input type="button" value="0" onclick="dis('0')"/> </td>
  37.           <td><input type="button" value="=" onclick="solve()" class="func"/> </td>
  38.           <td><input type="button" value="*" onclick="dis('*')" class="func"/> </td>
  39.        </tr>
  40.     </table>
  41.  
  42.     <script type="text/javascript" src="js/CalcScript.js"></script>
  43. </body>
  44. </html>
  45. ---------------------------------------------------------------------------------------------------------------------------------------
  46. //css
  47. *{
  48.     background-color:aliceblue;
  49. }
  50. .title{
  51.     margin-left: 43%;
  52.     margin-bottom: 10px;
  53.     text-align:center;
  54.     width: 210px;
  55.     color:rgb(0, 0, 0);
  56.     border: none;
  57.     font-size: 50px;
  58.     }
  59.  
  60. input[type="button"]{
  61.     font-size: 30px;
  62.     height: 100%;
  63.     background-color:rgb(214, 210, 209);
  64.     color: black;
  65.     border: solid black 2px;
  66.     width:100%
  67.     }
  68. input[type="button"]:hover{
  69.     width: 95%;
  70.     height: 95%;
  71.     font-size: 25px;
  72.     background-color: rgb(209, 237, 245);
  73. }
  74. input[type="text"]{
  75.     font-size: 30px;
  76.     height: 93%;
  77.     background-color:white;
  78.     border: solid black 2px;
  79.     width:98%
  80.     }
  81.     table{
  82.         width: 500px;
  83.         margin-left: 33%;
  84.         margin-top: 5%;
  85.         border: none;
  86.     }th{
  87.         margin-left: 100px;
  88.         font-size: 40px;
  89.         text-align: center;
  90.         background-color: rgb(214, 210, 209);
  91.     }
  92.     td{
  93.         height: 100px;
  94.         width: 500px;
  95.         border: none;
  96.     }
  97.    
  98.     input.func{
  99.         background-color: rgb(173, 173, 173);
  100.     }
  101. ---------------------------------------------------------------------------------------------------------------------------------------
  102. //js
  103. function dis(val){
  104.     document.getElementById("result").value+=val
  105. }
  106. function solve(){
  107.     let x = document.getElementById("result").value
  108.     let y = eval(x)
  109.     document.getElementById("result").value = y
  110. }
  111. function clr(){
  112.     document.getElementById("result").value = ""
  113. }
  114.  
  115.  
Add Comment
Please, Sign In to add comment