开发者

.rows.length, doesn't work in firefox

I have a problem with JavaScript code, it works in IE7/8, but doesn't work in Firefox

for (var i = 1; i < document.getElementById(obj).rows.length; i++)
{
    var numColumns = document.getElementById(obj).rows(i).cells.length;
    if (numColumns > 0)
    {
        if (document.getElementById(obj).rows(i).cells(numColumns - 1).children.length > 1)
        {
            if (document.getElementById(obj).rows(i).cells(numColumns - 1).children(1).checked == true)
            {
                var ctrlId = document.getElementById(obj).rows(i).cells(numColumns - 1).children(1).id.replace('chk', 'txt')
开发者_开发技巧                workflowIds = workflowIds + (workflowIds == '' ? '' : '|') + document.getElementById(ctrlId).value;
            }
        }
    }
}

The error: "Error: document.getElementById(obj).rows is not a function ... etc"

Thanks !!!


Use [], not (), for rows and cells (they're arrays !)

document.getElementById(obj).rows[i].cells[numColumns - 1] //...

Edit : the same for children. And prefer childNodes, I don't know if children is understood by FF.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜