AlexC
AlexC

Reputation: 9661

.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 !!!

Upvotes: 1

Views: 1942

Answers (1)

Pik&#39;
Pik&#39;

Reputation: 7087

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.

Upvotes: 5

Related Questions