以下是函数中的计算公式。目前我在计算结果上遇到麻烦,一些输出在文本框中显示“Infinity”。
需要帮助。
function Calc() {
let arr = document.getElementsByName('qty');
let tot = 0;
for (let i = 0; i < arr.length; i++) {
let radios = document.getElementsByName("group" + (i + 1));
for (let j = 0; j < radios.length; j++) {
let radio = radios[j];
if (radio.value == "Yes" && radio.checked) {
tot += parseInt(arr[i].value);
}
}
}
document.getElementById('total').value = tot;
var stdHour = ((tot * 1.15) / 3600);
document.getElementById('stdHour').value = stdHour.toFixed(4);
var earnHour = ((tot * 1.15) / 3600) * document.getElementById('unitNum').value;
document.getElementById('earnHour').value = earnHour.toFixed(3);
var headC = ((earnHour / 19.8) / document.getElementById('numDays').value) || 0.00;
document.getElementById('hc').value = headC.toFixed(3);
var earnDays = ((document.getElementById('unitNum').value / ((document.getElementById('numHeadC').value / stdHour) * 5.27)) / 3) || 0.00;
document.getElementById('days').value = earnDays.toFixed(3);
document.getElementById('perday').value = ((document.getElementById('numHeadC').value / stdHour * 5.27) * 3).toFixed(0);
document.getElementById('hcperday').value = ((document.getElementById('output').value / 19.8) * stdHour).toFixed(3);
}