-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcalculator.php
143 lines (137 loc) · 4.52 KB
/
calculator.php
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php require 'functions.php'; ?>
<!doctype html>
<html lang="id">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href='https://www.hockeycomputindo.com/favicon.ico' rel='icon' type='image/x-icon'/>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<title>Inventori Apps - Calculator</title>
</head>
<body>
<div class="container">
<?php require 'head.php';?>
<?php require 'nav.php';?>
<div class="row">
<div class="col-12 col-12 p-3 p-md-5 text-center">
<center>
<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 = document.getElementById("result").value
let y = eval(x)
document.getElementById("result").value = y
}
//function that clear the display
function clr()
{
document.getElementById("result").value = ""
}
</script>
<!-- for styling -->
<style>
.title{
margin-bottom: 10px;
text-align:center;
width: 210px;
color:green;
border: solid black 2px;
}
input[type="button"]
{
background-color:cyan;
color: black;
border: solid black 2px;
width:100%
}
input[type="text"]
{
background-color:white;
border: solid black 2px;
width:100%
}
</style>
<h1>Calculator Digital</h1>
<table border="1" class="table bg-dark rounded shadow">
<tr>
<td colspan="3">
<input type="text" class="rounded p-3" id="result" />
</td>
<td>
<input type="button" class="btn btn-danger btn-lg rounded" value="c" onclick="clr()" />
</td>
</tr>
<tr>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="1" onclick="dis('1')" />
</td>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="2" onclick="dis('2')" />
</td>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="3" onclick="dis('3')" />
</td>
<td>
<input type="button" value="/" class="btn btn-primary btn-lg rounded" onclick="dis('/')" />
</td>
</tr>
<tr>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="4" onclick="dis('4')" />
</td>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="5" onclick="dis('5')" />
</td>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="6" onclick="dis('6')" />
</td>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="-" onclick="dis('-')" />
</td>
</tr>
<tr>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="7" onclick="dis('7')" />
</td>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="8" onclick="dis('8')" />
</td>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="9" onclick="dis('9')" />
</td>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="+" onclick="dis('+')" />
</td>
</tr>
<tr>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="." onclick="dis('.')" />
</td>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="0" onclick="dis('0')" />
</td>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="=" onclick="solve()" />
</td>
<td>
<input type="button" class="btn btn-primary btn-lg rounded" value="x" onclick="dis('*')" />
</td>
</tr>
</table>
</center>
<br>
</div>
<div class="col-12 col-md-12 text-center">
<p class="text-center"><small>present by <a href="https://mesinkasironline.web.app" class="text-dark"> https://mesinkasironline.web.app</a></small>
</p>
</div>
</div>
</div>
</body>
</html>