MrDehH4ck3r

HML 5 CALCULATE

Jun 20th, 2023
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 3.10 KB | Source Code | 0 0
  1. <!DOCTYPE html>
  2. <html lang="fr-CD">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta http-equiv="Content-Type" content="text/html; utf-8" />
  6. <meta name="description" content="HTML, CSS, JS calculator" />
  7. <meta name="keywords" content="HTML, CSS, JS calculator" />
  8. <meta name="author" content="Mr Deh H4ck3r" />
  9. <title> HTML CALCULATOR </title>
  10. <style type="text/css">
  11.  input[type=button] {
  12.   color: white;
  13.   border-collaspe: collapse;
  14.   padding: 20px 20px;
  15.   border: 1px solid grey;
  16.   background-color: rebeccapurple;
  17.   font-size: 25px;
  18.   border-radius: 10%;
  19.   font-weight: 900;
  20.   border-radius: 5px;
  21.   width: 100%;
  22.   outline: none;
  23.   height: 75%;
  24.   }
  25.   table {
  26.   background-color: black;
  27.   border-radius: 15px;
  28.   height: 550px;
  29.   width: 350px;
  30.   box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;
  31.   }
  32.   input[type=button]:active {
  33.    color: red;
  34.    }
  35.    input[type=button]:focus {
  36.    color: red;
  37.    }
  38.   input[type=text] {
  39.   padding: 20px 20px;
  40.   text-align: left;
  41.   font-weight: 900;
  42.   border-radius: 10px;
  43.   color: #651FFF;
  44.   background-color: #DEDEF1;
  45.   border: 4px solid green;
  46.   box-shadow: 0px 0px 20px #cfcfcf;
  47.   }
  48.   input.btn {
  49.   background-color: #FF1744;
  50.   }
  51.   input.btn1 {
  52.   background-color: #F50057;
  53.   }
  54. </style>
  55. </head>
  56. <body>
  57. <table border="0" class="calculate()">
  58. <tr>
  59. <td colspan="3"><input id="result" type="text" disabled></td>
  60. <td><input type="button" value="del" onClick="clearScreen()" class="btn1" id="btn"></td>
  61. </tr>
  62. <tr>
  63. <td><input type="button" value="1" onClick="display('1')"></td>
  64. <td><input type="button" value="2" onClick="display('2')"></td>
  65. <td><input type="button" value="3" onClick="display('3')"></td>
  66. <td><input type="button" value="/" onClick="display('/')"></td>
  67. </tr>
  68. <tr>
  69. <td><input type="button" value="4" onClick="display('4')"></td>
  70. <th><input type="button" value="5" onClick="display('5')"></th>
  71. <td><input type="button" value="6" onClick="display('6')"></td>
  72. <td><input type="button" value="*" onClick="display('*')"></td>
  73. </tr>
  74. <tr>
  75. <td><input type="button" value="7" onClick="display('7')"></td>
  76. <td><input type="button" value="8" onClick="display('8')"></td>
  77. <td><input type="button" value="9" onClick="display('9')"></td>
  78. <td><input type="button" value="-" onClick="display('-')"></td>
  79. </tr>
  80. <tr>
  81. <td><input type="button" value="." onClick="display('.')"></td>
  82. <td><input type="button" value="0" onClick="display('0')"></td>
  83. <td><input type="button" id="btn" class="btn" value="=" onClick="calculate()"></td>
  84. <td><input type="button" value="+" onClick="display('+')"></td>
  85. </tr>
  86. </table>
  87. <script type="text/javascript">
  88.     // This function clear all the values
  89. function clearScreen() {
  90.     document.getElementById("result").value = "";
  91. }
  92.  
  93. // This function display values
  94. function display(value) {
  95.     document.getElementById("result").value += value;
  96. }
  97.  
  98. // This function evaluates the expression and returns result
  99. function calculate() {
  100.     var p = document.getElementById("result").value;
  101.     var q = eval(p);
  102.     document.getElementById("result").value = q;
  103. }
  104.  
  105.    
  106. </script>
  107. </body>
  108. </html>
Advertisement
Add Comment
Please, Sign In to add comment