-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
75 lines (73 loc) · 3.07 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Calculator</title>
<!-- CSS -->
<link rel="stylesheet" href="calci.css" />
<!-- Bootstrap -->
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous"
/>
<!-- Calculator working script -->
<script>
//function that display value
function dis(val) {
document.getElementById("result").value += val;
}
//function that evaluates the digit and return result
function solve() {
let x = eval(document.getElementById("result").value);
document.getElementById("result").value = x;
}
//function that clear the display
function clr() {
document.getElementById("result").value = "";
}
</script>
</head>
<body>
<section id="main">
<div class="container-fluid">
<div class="jumbotron">
<div class="row">
<input type="text" name="ayan" id="result" disabled/>
<button class="btn submit" onclick="clr()" style="width: 19rem" type="submit">
AC
</button>
<div class="col-sm-3">
<input type="button" class="btn" value="1" onclick="dis('1')" />
<input type="button" class="btn" value="2" onclick="dis('2')" />
<input type="button" class="btn" value="3" onclick="dis('3')" />
<input type="button" class="btn" value="/" onclick="dis('/')" />
</div>
<div class="col-sm-3">
<input type="button" class="btn" value="4" onclick="dis('4')" />
<input type="button" class="btn" value="5" onclick="dis('5')" />
<input type="button" class="btn" value="6" onclick="dis('6')" />
<input type="button" class="btn" value="-" onclick="dis('-')" />
</div>
<div class="col-sm-3">
<input type="button" class="btn" value="7" onclick="dis('7')" />
<input type="button" class="btn" value="8" onclick="dis('8')" />
<input type="button" class="btn" value="9" onclick="dis('9')" />
<input type="button" class="btn" value="+" onclick="dis('+')" />
</div>
<div class="col-sm-3">
<input type="button" class="btn" value="." onclick="dis('.')" />
<input type="button" class="btn" value="0" onclick="dis('0')" />
<!-- solve function call function solve to evaluate value -->
<input type="button" class="btn" value="=" onclick="solve()" />
<input type="button" class="btn" value="*" onclick="dis('*')" />
</div>
</div>
</div>
</div>
</section>
</body>
</html>