Javascript函数在Chrome中提供NaN,但在IE中运行良好 [英] Javascript function gives NaN in Chrome but woks fine in IE
问题描述
大家好
我有以下javascript代码在IE中正常工作。但是,当我在Chrome中加载此页面时,字段总数会被NaN填充。任何帮助将不胜感激..
<前lang =cs>函数Addvalue(){
var gv = document.getElementById( <%= Grid_Insert.ClientID%>);
var gvRowCount = gv.rows.length;
var total = 0 ;
for (i = 1 ; i < ; gvRowCount; i ++){
for (j = 2 ; j < span class =code-keyword>< 15 ; j ++){
var a = parseInt(gv.rows [i] .cells [j] .childNodes [ 0 ]。 value < /跨度>);
if (j < 14 )
{
if (!isNaN(a))
{
total = total + parseInt(gv .rows [i] .cells [j] .childNodes [ 0 ]。 value );
}
}
如果(j == 14 ){
gv.rows [i] .cells [j] .innerText = total;
}
}
}
}
行
如果(!isNaN(a) ))) 我在 IE但是Retrn false 我在中运行 Chrome ..
请帮助
您的测试if(value != NaN)不是正确的测试。
使用:if(!isNaN(value))
Hi Everybody
I have the following javascript code that works fine in IE . But when i load this page in chrome the fields total get filled with NaN. Any help would be appreciated..
function Addvalue() {
var gv = document.getElementById("<%=Grid_Insert.ClientID %>");
var gvRowCount = gv.rows.length;
var total = 0;
for (i = 1; i < gvRowCount; i++) {
for (j = 2; j < 15; j++) {
var a = parseInt(gv.rows[i].cells[j].childNodes[0].value);
if (j < 14)
{
if (!isNaN(a))
{
total = total + parseInt(gv.rows[i].cells[j].childNodes[0].value);
}
}
if (j == 14) {
gv.rows[i].cells[j].innerText = total;
}
}
}
}
the line
if (!isNaN(a)) returns true when i Run my page in IE but Retrn false when I run in Chrome..
Pls Help
Your testif(value != NaN)is not the proper test.
Use:if(!isNaN(value) )
这篇关于Javascript函数在Chrome中提供NaN,但在IE中运行良好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!