-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculatricev2.html
124 lines (103 loc) · 3.87 KB
/
calculatricev2.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculatrice</title>
<style>
*
{
margin: 0;
padding: 0;
}
.button
{
width: 50px;
height: 50px;
font-size: 25;
margin: 2px;
cursor: pointer;
}
.txtView
{
width: 205px;
height: 50px;
margin: 5px;
padding: 5px;
}
.main
{
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%)translateY(-50%);
}
body
{
/*background-image: linear-gradient(to right, #00AAFF, #00FF6C);*/
background-color: yellowgreen;
}
</style>
<script>
function insert(num)
{
document.form.txtView.value = document.form.txtView.value + num;
}
function equal()
{
var expres = document.form.txtView.value;
if(expres)
{
document.form.txtView.value = eval(expres);
}
}
function cleanF()
{
document.form.txtView.value = "";
}
function back()
{
var expres = document.form.txtView.value;
document.form.txtView.value = expres.substring(0, expres.length - 1);
}
</script>
</head>
<body>
<div class="bg"></div>
<div class="main">
<form name="form">
<input class="txtView" name="txtView">
</form>
<table>
<tr>
<td><input class="button" type="button" value="C" onclick="cleanF();"></td>
<td><input class="button" type="button" value="<" onclick="back();"></td>
<td><input class="button" type="button" value="/" onclick="insert(this.value);"></td>
<td><input class="button" type="button" value="*" onclick="insert(this.value);"></td>
</tr>
<tr>
<td><input class="button" type="button" value="7" onclick="insert(this.value);"></td>
<td><input class="button" type="button" value="8" onclick="insert(this.value);"></td>
<td><input class="button" type="button" value="9" onclick="insert(this.value);"></td>
<td><input class="button" type="button" value="-" onclick="insert(this.value);"></td>
</tr>
<tr>
<td><input class="button" type="button" value="4" onclick="insert(this.value);"></td>
<td><input class="button" type="button" value="5" onclick="insert(this.value);"></td>
<td><input class="button" type="button" value="6" onclick="insert(this.value);"></td>
<td><input class="button" type="button" value="+" onclick="insert(this.value);"></td>
</tr>
<tr>
<td><input class="button" type="button" value="1" onclick="insert(this.value);"></td>
<td><input class="button" type="button" value="2" onclick="insert(this.value);"></td>
<td><input class="button" type="button" value="3" onclick="insert(this.value);"></td>
<td rowspan="5"><input style="height: 106px;" class="button" type="button" value="=" onclick="equal();"></td>
</tr>
<tr>
<td colspan="2"><input style="width:106px" class="button" type="button" value="0" onclick="insert(this.value);"></td>
<td><input class="button" type="button" value="." onclick="insert(this.value);"></td>
</tr>
</table>
</div>
</body>
</html>