我有這個問題,我添加8文本框,它工作正常,但是當我添加更多文本框如16文本框它不添加最後一個文本框。有沒有人遇到過這個問題?提前致謝。此外,使用Javascript功能添加多個文本框
function sum() {
var basicpay = document.getElementById('basicpay').value;
var overtime = document.getElementById('overtime').value;
var regularholiday = document.getElementById('regularholiday').value;
var specialholiday = document.getElementById('specialholiday').value;
var allowanceday = document.getElementById('allowanceday').value;
var others = document.getElementById('others').value;
var grosspay = document.getElementById('grosspay').value;
var monthpay13 = document.getElementById('monthpay13').value;
var absent = document.getElementById('absent').value;
var tardiness = document.getElementById('tardiness').value;
var sss = document.getElementById('sss').value;
var pagibig = document.getElementById('pagibig').value;
var philhealth = document.getElementById('philhealth').value;
var cashadvances = document.getElementById('cashadvances').value;
var withholdingtax = document.getElementById('withholdingtax').value;
var others = document.getElementById('others').value;
var result =
parseInt(basicpay) +
parseInt(overtime) +
parseInt(regularholiday) +
parseInt(specialholiday) +
parseInt(allowanceday) +
parseInt(others) +
parseInt(grosspay) +
parseInt(absent) +
parseInt(tardiness) +
parseInt(sss) +
parseInt(pagibig) +
parseInt(philhealth) +
parseInt(cashadvances) +
parseInt(withholdingtax) +
parseInt(others) +
parseInt(monthpay13);
if (!isNaN(result)) {
document.getElementById('totalincome').value = result;
}
}
爲什麼你將'others'設置兩次並在'result'公式中添加兩次? – Barmar