在Javascript中添加多個變量之和的正確方法是什麼?用parseInt()將變量求和;不工作
這就是我想要做的。我試過,沒有引用我的變量。我沒有得到NaN或Undefined或任何東西。沒有任何輸出。
function setstat(){
document.getElementById('date').value = window.opener.document.getElementById('thisday').value;
document.getElementById('name').value = window.opener.document.getElementById('element_7').value;
document.getElementById('time').value = window.opener.document.getElementById('stwa').value;
inbcalls = window.opener.document.getElementById('element_6').value;
document.getElementById('totinb').value = inbcalls;
inbcallsp = parseInt("inbcalls",10);
asaptotal = window.opener.document.getElementById('asapcalls').value;
document.getElementById('asaptot').value = asaptotal;
asaptotalp = parseInt("asaptotal",10);
faxtotal = window.opener.document.getElementById('faxcalls').value;
document.getElementById('faxtot').value = faxtotal;
faxtotalp = parseInt("faxtotal",10);
obtotal = window.opener.document.getElementById('obcalls').value;
document.getElementById('obtot').value = obtotal;
totalcalls = inboundcallsp + asaptotalp + faxtotalp + obtotalp;
document.getElementById('totsum').value = totalcalls;
}
您是否嘗試過在控制檯中追蹤每個人? – elclanrs
那麼,「faxtotal」不是一個整數,它是一個字符串。不知道你在做什麼,很難提供幫助。 JS控制檯在哪一天? –
開罐器和開罐器的領域是一樣的嗎?另外,檢查你的控制檯是否有錯誤。 – Ryan