forked from rajvir1602/calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.html
76 lines (68 loc) · 2.59 KB
/
calculator.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
<!DOCTYPE html>
<html>
<head>
<style>
#clear_all{
width: 100px;
}
#answer_style{
width: 500px;
color:white;
font-size: 100px;
}
.formstyle{
width: 500px;
height:660px;
margin: auto;
border: 2px solid black;
background-color: chocolate;
}
input{
width: 100px;
height: 100px;
background-color: blue;
color:white;
font-size: 30px;
}
</style>
<script type="text/javascript">
function fun() {
try{
var x = eval(forms.answer.value);
forms.answer.value = x;
}
catch(err){
forms.answer.value = "Error";
}
}
</script>
</head>
<body>
<div class="formstyle">
<form name="forms">
<input type="text" name="answer" id="answer_style">
<br><br>
<input type="button" value="1" onclick="forms.answer.value += '1'">
<input type="button" value="2" onclick="forms.answer.value += '2'">
<input type="button" value="3" onclick="forms.answer.value += '3'">
<br>
<input type="button" value="4" onclick="forms.answer.value += '4'">
<input type="button" value="5" onclick="forms.answer.value += '5'">
<input type="button" value="6" onclick="forms.asnwer.value += '6'">
<br>
<input type="button" value="7" onclick="forms.answer.value += '7'">
<input type="button" value="8" onclick="forms.answer.value += '8'">
<input type="button" value="9" onclick="forms.answer.value += '9'">
<br>
<input type="button" value="0" onclick="forms.answer.value += '0'">
<input type="button" value="+" onclick="forms.answer.value += '+'">
<input type="button" value="-" onclick="forms.answer.value += '-'">
<br>
<input type="button" value="*" onclick="forms.answer.value += '*'">
<input type="button" value="/" onclick="forms.answer.value += '/'">
<input type="button" value="=" onclick="fun()">
<input type="button" value="Clear" onclick="forms.answer.value=''" id="clear_all">
</form>
</div>
</body>
</html>