I have 2 custom functions for basically hiding and showing rows in a table. The code gets parent node’s rowIndex and the next available parent node’s rowIndex, and this determines the range of rows to either hide or show. Now, in place I coded checks to see if the parent node is the last available and if so then just show or hide everything up through the last row in the table.
There seems to be a bug in Internet Explorer 8.0. It is not handling the indexing of the rows properly, thus my code is hiding and showing the wrong rows. My code works flawless in Firefox 3.6.3. The problem is that my place of employment uses Internet Explorer.
Does anyone know of a work around? Or can help me understand why this happening? Possibily a more robust way of handling table rows for a hide .
I just starting programming in javascript about 1.5 months ago, so take it easy on me ?
[CODE]function nodeCollapse(nodeId, nodeType){
if (nodeType == ‘project’){
indexOf = getProjectIndexByCode(nodeId);
startPos = document.getElementById(‘pos’ + nodeId).rowIndex + 1;
if ((myProjects.length – 1) < (indexOf + 1)){
//this is the last project then the endPos is the last row
endPos = document.getElementById(‘encapsulation-table’).getElementsByTagName(‘tr’).length – 1;
}else{
endPos = document.getElementById(‘pos’ + myProjects[indexOf + 1].code).rowIndex – 1;
}
}else if (nodeType == ‘site’){
// if we are expanding or collapsing a site node
// not implemented yet
}
for (i=startPos;i<=endPos;i++){
document.getElementById(‘encapsulation-table’).getElementsByTagName(‘tr’)[i].style.display = ‘none’;
}
}
[CODE]function nodeExpand(nodeId, nodeType){
if (nodeType == ‘project’){
indexOf = getProjectIndexByCode(nodeId);
startPos = document.getElementById(‘pos’ + nodeId).rowIndex + 1;
if ((myProjects.length – 1) < (indexOf + 1)){
//this is the last project then the endPos is the last row
endPos = document.getElementById(‘encapsulation-table’).getElementsByTagName(‘tr’).length – 1;
}else{
endPos = document.getElementById(‘pos’ + myProjects[indexOf + 1].code).rowIndex – 1;
}
}else if (nodeType == ‘site’){
}
for (i=startPos;i<=endPos;i++){
document.getElementById(‘encapsulation-table’).getElementsByTagName(‘tr’)[i].style.display = ”;
}
}