-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnrr.js
26 lines (24 loc) · 962 Bytes
/
nrr.js
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
document.addEventListener("DOMContentLoaded", function () {
// NRR Calculator Input Handling
var nrrInputs = document.querySelectorAll(
"#fInngRuns, #sInngRuns, #fInngOvers, #sInngOvers"
);
nrrInputs.forEach(function (input) {
input.addEventListener("input", calculateNRR);
});
// Function to Calculate Net Run Rate (NRR)
function calculateNRR() {
var b1r = parseFloat(document.getElementById("fInngRuns").value) || 0;
var b1o = parseFloat(document.getElementById("fInngOvers").value) || 0;
var b2r = parseFloat(document.getElementById("sInngRuns").value) || 0;
var b2o = parseFloat(document.getElementById("sInngOvers").value) || 0;
if (b1o !== 0 && b2o !== 0) {
var frr = b1r / b1o;
var srr = b2r / b2o;
var calc = (frr - srr).toFixed(2);
document.getElementById("nrrTBF").value = calc;
} else {
document.getElementById("nrrTBF").value = "";
}
}
});