-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
51 lines (42 loc) · 1.39 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
<!DOCTYPE html>
<head>
</head>
<style>
input::-webkit-inner-spin-button {
-webkit-appearance: none;
}
input {
/* float: right; */
}
</style>
<body>
<div>Commission Calculator</div>
<div> Monday <input type="number" autofocus></div>
<div> Tuesday <input type="number"></div>
<div> Wednesday <input type="number"></div>
<div> Thursday <input type="number"></div>
<div> Friday <input type="number"></div>
<div id="Showme"> Total <input id="total" disabled></div>
<button onclick="window.location.reload()">Refresh </button>
<script>
var inputEle = document.querySelectorAll('input[type=number]');
for (let i = 0; i < inputEle.length; i++) {
inputEle[i].value = 0;
inputEle[i].addEventListener("keydown", function(event) {
calc(event, i);
});
}
function calc(event, eleIndex) {
var totalcomm = 0;
for (let ele = 0; ele < inputEle.length; ele++) {
totalcomm += parseInt(inputEle[ele].value) || 0;
}
document.getElementById("total").value = totalcomm;
if (event.keyCode == 13 || event.which == 13 || event.key == 'Enter') {
var next = Math.min(eleIndex + 1, inputEle.length - 1);
inputEle[next].focus();
}
}
</script>
</body>
</html>