i'm trying to loop through all the cells in a table and do a comparison on the value. 

```
            var table = document.getElementById("assignedvlans");
            alert(table);
            alert($('#assignedvlans tbody tr').length);
            for (var i = 0, cell; cell = table.cells[i]; i++) {
                 //iterate through all cells in table.
                 alert('in the loop');
                 alert(cell.val());
                 if (cell.val == IdforVlanToAdd)
                 {
                    alert('This vlan is already associated with the port.');
                    $bexit = true;
                    break;
                 }                  
            }

```

When i test this code, the alert(table) code is working - it returns "object HTMLTableElement" and the alert for the table lengths returns 4, which is also correct. 
But the alert statements inside the loop never happen.
Can you tell me where i'm going wrong with the loop control? 
Thanks.