Loading ...
[Plus récent] [Plus ancien] [Meilleur rang] [Mauvais rang]

PCR Postit

Javascript

::

Cacher Afficher les lignes d'un tableau en javascript

[Trackback]
Date : 2007-10-24@11:17:32
Rang : 0

La fonction suivante permet d'afficher de cacher/afficher toutes les lignes ayant pour classe css rowClass du tableau identifié tableId.

function displayRowClass(tableId,rowClass)
{
        var table = document.getElementById(tableId);
        var display = 'none';
        for(i in table.rows)
        {
                row = table.rows[i];
                if(row.className == rowClass)
                {
                        if(row.style.display == 'none')
                        {
                                /**Test si c'est IE ou pas*/
                                display = document.all != undefined ? 'block' : 'table-row';
                        }
                        else
                        {
                                display = 'none';
                        }
                        row.style.display = display;
                }
        }
}