-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcal.html
121 lines (100 loc) · 4.14 KB
/
cal.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
5<!-- Create a simple Program to build the Calculator in JavaScript using with HTML and CSS web languages. -->
<!DOCTYPE html>
<html lang="en">
<head>
<title> Calculator </title>
<style>
body {
padding: 0;
background-color: rgb(246, 187, 246);
margin: 6%;
}
.formstyle {
width: 270px;
height: 540px;
margin: auto;
border-radius: 5px;
padding: 20px;
background-color: white;
border: blueviolet;
}
input {
width: 20px;
border: none;
color: blueviolet;
border-radius: 5px;
padding: 26px;
margin: 5px;
font-size: 15px;
box-shadow: 1px 2px 3px 0px blueviolet;
}
#calc {
color: black;
width: 220px;
border-radius: 3px;
padding: 20px;
box-shadow: 0 1px 2px 0 blueviolet;
}
span {
display: flex;
}
span>input {
color: white;
background-color: rgb(128, 74, 177);
width: 125px;
border-radius: 3px;
padding: 20px;
background-color: rgb(128, 74, 177);
color: white;
}
#numbers>input:hover {
color: white;
background-color: rgb(233, 108, 133);
}
#numbers>input {
background-color: violet;
}
</style>
</head>
<body>
<div class="formstyle">
<form name="form1">
<!-- This input box shows the button pressed by the user in calculator. -->
<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. -->
<div id="numbers">
<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 += '+' " class="op">
<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 += '-' " class="op">
<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 += '*' " class="op">
<br> <br>
<input type="button" value="/" onclick="form1.answer.value += '/' " class="op">
<input type="button" value="0" onclick="form1.answer.value += '0' ">
<input type="button" value="." onclick="form1.answer.value += '.' " class="op">
<!-- 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) " class="op">
<br>
</div>
<!-- Display the Cancel button and erase all data entered by the user. -->
<br>
<span id="span">
<input type="button" value="Delete" class="delete"
onclick="form1.answer.value =form1.answer.value.toString().slice(0,-1) ">
<input type="button" value="Clear All" onclick="form1.answer.value = ' ' " id="clear">
</span>
<br>
</form>
</div>
</body>
</html>