Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="fr-CD">
- <head>
- <meta charset="utf-8" />
- <meta http-equiv="Content-Type" content="text/html; utf-8" />
- <meta name="description" content="HTML, CSS, JS calculator" />
- <meta name="keywords" content="HTML, CSS, JS calculator" />
- <meta name="author" content="Mr Deh H4ck3r" />
- <title> HTML CALCULATOR </title>
- <style type="text/css">
- input[type=button] {
- color: white;
- border-collaspe: collapse;
- padding: 20px 20px;
- border: 1px solid grey;
- background-color: rebeccapurple;
- font-size: 25px;
- border-radius: 10%;
- font-weight: 900;
- border-radius: 5px;
- width: 100%;
- outline: none;
- height: 75%;
- }
- table {
- background-color: black;
- border-radius: 15px;
- height: 550px;
- width: 350px;
- box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;
- }
- input[type=button]:active {
- color: red;
- }
- input[type=button]:focus {
- color: red;
- }
- input[type=text] {
- padding: 20px 20px;
- text-align: left;
- font-weight: 900;
- border-radius: 10px;
- color: #651FFF;
- background-color: #DEDEF1;
- border: 4px solid green;
- box-shadow: 0px 0px 20px #cfcfcf;
- }
- input.btn {
- background-color: #FF1744;
- }
- input.btn1 {
- background-color: #F50057;
- }
- </style>
- </head>
- <body>
- <table border="0" class="calculate()">
- <tr>
- <td colspan="3"><input id="result" type="text" disabled></td>
- <td><input type="button" value="del" onClick="clearScreen()" class="btn1" id="btn"></td>
- </tr>
- <tr>
- <td><input type="button" value="1" onClick="display('1')"></td>
- <td><input type="button" value="2" onClick="display('2')"></td>
- <td><input type="button" value="3" onClick="display('3')"></td>
- <td><input type="button" value="/" onClick="display('/')"></td>
- </tr>
- <tr>
- <td><input type="button" value="4" onClick="display('4')"></td>
- <th><input type="button" value="5" onClick="display('5')"></th>
- <td><input type="button" value="6" onClick="display('6')"></td>
- <td><input type="button" value="*" onClick="display('*')"></td>
- </tr>
- <tr>
- <td><input type="button" value="7" onClick="display('7')"></td>
- <td><input type="button" value="8" onClick="display('8')"></td>
- <td><input type="button" value="9" onClick="display('9')"></td>
- <td><input type="button" value="-" onClick="display('-')"></td>
- </tr>
- <tr>
- <td><input type="button" value="." onClick="display('.')"></td>
- <td><input type="button" value="0" onClick="display('0')"></td>
- <td><input type="button" id="btn" class="btn" value="=" onClick="calculate()"></td>
- <td><input type="button" value="+" onClick="display('+')"></td>
- </tr>
- </table>
- <script type="text/javascript">
- // This function clear all the values
- function clearScreen() {
- document.getElementById("result").value = "";
- }
- // This function display values
- function display(value) {
- document.getElementById("result").value += value;
- }
- // This function evaluates the expression and returns result
- function calculate() {
- var p = document.getElementById("result").value;
- var q = eval(p);
- document.getElementById("result").value = q;
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment