【发布时间】:2012-07-05 02:24:49
【问题描述】:
在Javascript中添加多个变量之和的正确方法是什么?
这就是我想要做的。我已经尝试过在变量周围加引号和不加引号。我没有得到 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;
}
【问题讨论】:
-
您是否尝试过在控制台中跟踪它们中的每一个?
-
好吧,“faxtotal”不是一个整数,而是一个字符串。在不知道你实际在做什么的情况下,很难提供帮助。 JS 控制台日是什么日子?
-
opener和openee的域名一样吗?另外,请检查您的控制台是否有错误。
-
你知道吗,我被拒绝了,别理我。无论如何,谢谢你们。我花了几个小时来修复最简单的事情,因为我不知道如何使用 firebug。未能指出“inboundcallsp”未定义。
标签: javascript variables add parseint