-
Notifications
You must be signed in to change notification settings - Fork 83
/
INDEX.html
103 lines (95 loc) · 3.13 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>JavaScript Calculator</title>
<style>
h1 {
text-align: center;
padding: 15px;
color: BLACK;
align-content: center;
letter-spacing: 2px;
}
#clear {
width: 250px;
border: 3px solid gray;
border-radius: 3px;
padding: 20px;
background-color: rgb(255, 153, 139);
}
.formstyle {
width: 250px;
height: auto;
margin: auto;
border: 10px solid rgb(0, 0, 0);
border-radius: 5px;
padding: 18px;
background-color: rgb(216, 204, 204);
}
input {
width: 20px;
background-color: rgb(255, 79, 25);
color: rgb(231, 216, 216);
border: 3px solid gray;
border-radius: 5px;
padding: 20px;
margin: 5px;
font-size: 20px;
}
#calc {
width: 200px;
border: 5px solid black;
border-radius: 3px;
padding: 20px;
margin: auto;
}
</style>
</head>
<body>
<h1>CALCULATOR</h1>
<div class="formstyle">
<form name="form1">
<input id="calc" type="text" name="answer" /> <br />
<br />
<!-- Display the calculator button on the screen. -->
<!-- onclick() function display the number prsses by the user. -->
<input type="button" value="1" onclick="form1.answer.value += '1' " />
<input type="button" value="2" onclick="form1.answer.value += '2' " />
<input type="button" value="3" onclick="form1.answer.value += '3' " />
<input type="button" value="+" onclick="form1.answer.value += '+' " />
<br />
<br />
<input type="button" value="4" onclick="form1.answer.value += '4' " />
<input type="button" value="5" onclick="form1.answer.value += '5' " />
<input type="button" value="6" onclick="form1.answer.value += '6' " />
<input type="button" value="-" onclick="form1.answer.value += '-' " />
<br />
<br />
<input type="button" value="7" onclick="form1.answer.value += '7' " />
<input type="button" value="8" onclick="form1.answer.value += '8' " />
<input type="button" value="9" onclick="form1.answer.value += '9' " />
<input type="button" value="*" onclick="form1.answer.value += '*' " />
<br />
<br />
<input type="button" value="/" onclick="form1.answer.value += '/' " />
<input type="button" value="0" onclick="form1.answer.value += '0' " />
<input type="button" value="." onclick="form1.answer.value += '.' " />
<!-- When we click on the '=' button, the onclick() shows the sum results on the calculator screen. -->
<input
type="button"
value="="
onclick="form1.answer.value = eval(form1.answer.value) "
/>
<br />
<!-- Display the Cancel button and erase all data entered by the user. -->
<input
type="button"
value="Clear All"
onclick="form1.answer.value = ' ' "
id="clear"
/>
<br />
</form>
</div>
</body>
</html>