-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalc.html
More file actions
131 lines (122 loc) · 3.71 KB
/
calc.html
File metadata and controls
131 lines (122 loc) · 3.71 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
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
125
126
127
128
129
130
131
<!DOCTYPE html>
<html lang="en">
<head>
<title>Calculator</title>
</head>
<style type="text/css">
h1 {
text-align: center;
}
form {
margin: auto;
width: 40%;
}
.row-container {
display: flex;
flex-direction: row;
justify-content: space-between;
margin: 5px;
}
.form-group {
display: flex;
margin: 5px;
width: 50%;
justify-content: space-between;
}
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none; /*removes the default arrows from elements*/
margin: 0;
}
/* Firefox */
input[type=number] {
-moz-appearance: textfield; /*handles the removal of arrows on inputs with type "number" */
}
</style>
<body>
<h1>Calculator</h1>
<form>
<p>Inputs only accept numerical values.</p>
<div class="row-container">
<div class="form-group">
<label for="jan">January</label>
<input type="number" id="jan" name="qty" onblur="findTotal()" />
</div>
<div class="form-group">
<label for="feb">February</label>
<input type="number" id="feb" name="qty" onblur="findTotal()" />
</div>
</div>
<div class="row-container">
<div class="form-group">
<label for="mar">March</label>
<input type="number" id="mar" name="qty" onblur="findTotal()" />
</div>
<div class="form-group">
<label for="apr">April</label>
<input type="number" id="apr" name="qty" onblur="findTotal()" />
</div>
</div>
<div class="row-container">
<div class="form-group">
<label for="may">May</label>
<input type="number" id="may" name="qty" onblur="findTotal()" />
</div>
<div class="form-group">
<label for="jun">June</label>
<input type="number" id="jun" name="qty" onblur="findTotal()" />
</div>
</div>
<div class="row-container">
<div class="form-group">
<label for="jul">July</label>
<input type="number" id="jul" name="qty" onblur="findTotal()" />
</div>
<div class="form-group">
<label for="aug">August</label>
<input type="number" id="aug" name="qty" onblur="findTotal()" />
</div>
</div>
<div class="row-container">
<div class="form-group">
<label for="sep">September</label>
<input type="number" id="sep" name="qty" onblur="findTotal()" />
</div>
<div class="form-group">
<label for="oct">October</label>
<input type="number" id="oct" name="qty" onblur="findTotal()" />
</div>
</div>
<div class="row-container">
<div class="form-group">
<label for="nov">November</label>
<input type="number" id="nov" name="qty" onblur="findTotal()" />
</div>
<div class="form-group">
<label for="dec">December</label>
<input type="number" id="dec" name="qty" onblur="findTotal()" />
</div>
</div>
<div style="text-align: center;">
<label for="total"><strong>Total Yearly Amount:</strong></label>
<input type="text" id="total" aria-live="polite" disabled />
</div>
<p>Purpose is to play with JavaScript and test ARIA Live announcements.</p>
<footer>
<a href="http://robertjmccaffery.com/examples.html">Back to Examples</a> | <a href="http://robertjmccaffery.com/">Home</a>
</footer>
</form>
<script>
function findTotal() {
var arr = document.getElementsByName('qty');
var tot = 0;
for (var i = 0; i < arr.length; i++) {
if (parseInt(arr[i].value))
tot += parseInt(arr[i].value);
}
document.getElementById('total').value = tot;
}
</script>
</body>
</html>