Bonjour à tous,

J'ai un tableau de données et je souhaite pouvoir afficher ou masquer certaines colonnes avec des checkbox. J'ai adapté un script que j'ai trouvé sur Internet qui fonctionne très bien sous Firefox mais pas sous IE8.

Voici l'erreur que j'obtiens sous IE8 :

Message : '0.style' a la valeur Null ou n'est pas un objet.
Ligne : 8
Caractère : 7
Voici mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
<html>
 
  <script type="text/javascript">
 
    function inverse(ID, name){
      var table = document.getElementById(ID);
      var detail = document.getElementsByName(name);
      if (detail[0].style.display == "table-cell"){
        for(var i = 0; i < detail.length; ++i) detail[i].style.display = "none";
      } else {
        for(var i = 0; i < detail.length; ++i) detail[i].style.display = "table-cell";
      }
    }
 
  </script>
 
  <body onload="inverse('tb', 'col0'); inverse('tb', 'col1'); inverse('tb', 'col2'); inverse('tb', 'col3');">
    Masquer/Afficher Col0 : <input type='checkbox' name='checkcol0' onClick="inverse('tb', 'col0')"; CHECKED><BR>
    Masquer/Afficher Col1 : <input type='checkbox' name='checkcol1' onClick="inverse('tb', 'col1')"; CHECKED><BR> 
    Masquer/Afficher Col2 : <input type='checkbox' name='checkcol2' onClick="inverse('tb', 'col2')"; CHECKED><BR> 
    Masquer/Afficher Col3 : <input type='checkbox' name='checkcol3' onClick="inverse('tb', 'col3')"; CHECKED><BR>
    <BR>     
    <table border="1" id="tb">
      <tr>
        <td name="col0">Nom</td>
        <td name="col1">Prénom</td>
        <td name="col2">Age</td>
        <td name="col3">Ville</td>
     </tr>
     <tr>
        <td name="col0">Dupont</td>
        <td name="col1">Henri</td>
        <td name="col2">25</td>
        <td name="col3">Rennes</td>
     </tr>
     <tr>
        <td name="col0">Durand</td>
        <td name="col1">Paul</td>
        <td name="col2">35</td>
        <td name="col3">Lyon</td>       
      </tr>
      <tr>
        <td name="col0">Martin</td>
        <td name="col1">Claude</td>
        <td name="col2">40</td>
        <td name="col3">Paris</td>
      </tr>  
    </table> 
  </body>
 
</html>
Quelqu'un serait-il en mesure de me dire si ce code peut être adapté pour fonctionner à la fois sous Firefox et IE8 (ou version antérieur) et si oui, comment ?

Merci d'avance à tous ceux qui pourrons m'aider.

Snheed