Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
61 lines (57 loc) · 2.96 KB
/
Copy pathindex.html
File metadata and controls
61 lines (57 loc) · 2.96 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Calculator</title>
<link rel="stylesheet" href="style.css">
<script>
function assignValue(val) {
if (calculator.display.value == Infinity) {
calculator.display.value = val;
} else {
calculator.display.value += val;
}
}
</script>
</head>
<body>
<form class="calc" name="calculator">
<table>
<tr>
<td colspan="5">
<input type="text" name="display" id="display" disabled>
</td>
</tr>
<tr>
<td><input type="button" name="one" value="1" onclick="assignValue('1')"></td>
<td><input type="button" name="two" value="2" onclick="assignValue('2')"></td>
<td><input type="button" name="three" value="3" onclick="assignValue('3')"></td>
<td><input type="button" class="operator" name="plus" value="+" onclick="calculator.display.value += '+'"></td>
<td><input type="button" class="operator" name="power" value="**" onclick="calculator.display.value += '**'"></td>
</tr>
<tr>
<td><input type="button" name="four" value="4" onclick="assignValue('4')"></td>
<td><input type="button" name="five" value="5" onclick="assignValue('5')"></td>
<td><input type="button" name="six" value="6" onclick="assignValue('6')"></td>
<td><input type="button" class="operator" name="minus" value="-" onclick="calculator.display.value += '-'"></td>
<td><input type="button" name="power2" value="^2" onclick="calculator.display.value += '**2'"></td>
</tr>
<tr>
<td><input type="button" name="seven" value="7" onclick="assignValue('7')"></td>
<td><input type="button" name="eight" value="8" onclick="assignValue('8')"></td>
<td><input type="button" name="nine" value="9" onclick="assignValue('9')"></td>
<td><input type="button" class="operator" name="times" value="x" onclick="calculator.display.value += '*'"></td>
<td><input type="button" class="operator" name="div" value="/" onclick="calculator.display.value += '/'"></td>
</tr>
<tr>
<td><input type="button" id="clear" name="clear" value="c" onclick="calculator.display.value = ''"></td>
<td><input type="button" name="zero" value="0" onclick="assignValue('0')"></td>
<td><input type="button" name="zero" value="." onclick="assignValue('.')"></td>
<td><input type="button" name="doit" value="="onclick="calculator.display.value = eval(calculator.display.value)"></td>
<td><input type="button" name="zero" value="%" onclick="calculator.display.value = eval(calculator.display.value /100)"></td>
</tr>
</table>
</form>
</body>
</html>