Bonjour a tous.

Voila mon probleme, je souhaite utiliser un radio bouton general qui permettra aux utilisateurs de directement tout mettre a Oui ou Non directement sans etre obliger de cocher Oui ou Non un par un

Voila ma partie Javascript :
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
<script language=javascript1.1>
function radio(nbRB){
 
if(document.forms.validation.validG[0].checked == false)
  {
    for(i=1; i<=nbRB; i++)
      {
        document.forms.validation.valid + i + [0].checked = false;
        document.forms.validation.valid + i + [1].checked = true;
      }  
  }
  else
  {    
    for(i=1; i<=nbRB; i++)
      { 
        document.forms.validation.valid + i + [0].checked = true; 
        document.forms.validation.valid + i + [1].checked = false;
      }
  } 
}
</script>
J'ai essayé de changer le :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
 document.forms.validation.valid + i + [0].checked = true;
en
Code : Sélectionner tout - Visualiser dans une fenêtre à part
 document.getElementByName("valid"+i)[0].checked = true;
ou avec le getElementById en faisant les changements appropriés mais rien n'y fais


Et voila ma partie en PHP/MySQL :
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
    $req = "SELECT * FROM COMMENTAIRES WHERE comm_billet_id=".$id." ORDER BY comm_date DESC;";
 
    include('../include/inc_connect.php');
 
    $result = mysql_query($req) or die(mysql_error());
    $nbchps = mysql_num_rows($result);
 
    echo '<form action=validComm.php method=POST name="validation">';
 
    echo '<table border=1 width=75% align=center>';
 
    echo '<tr>';
    echo '<th> Identifiant </th>';
    echo '<th> Pseudo </th>';
    echo '<th> Date </th>';
    echo '<th> Texte </th>';
    echo '<th> Validation <br>';
    echo '<input type=radio name="validG" onChange=(radio('.$nbchps.'))> Tout oui';
    echo '<input type=radio name="validG" checked onChange=(radio('.$nbchps.'))> Tout non';
    echo'</th>';
    echo '</tr>';
 
    $i = 0;
 
    while(($enr = mysql_fetch_row($result))!= NULL)
    {
      list($date,$heure) = explode(" ",$enr[2]);
      list($annee,$mois,$jour) = explode("-",$date);
      $date = $jour.'/'.$mois.'/'.$annee;
 
      $nomRB = "valid" & $i;
 
      echo '<tr>';
      echo '<td align=center width=1%>'.$enr[0].'</td>';
      echo '<td align=center width=12%>'.$enr[1].'</td>';
      echo '<td align=center width=12%>'.$enr[2].'</td>';
      echo '<td align=center width=15%>'.$enr[3].'</td>'; 
      echo '<td align=center width=15%> <input type=radio name='.$nomRB.' > Oui'; 
      echo '<input type=radio name='.$nomRB.' checked> Non </td>';
      echo '</tr>';
      $i += 1;
    }
 
    include('../include/inc_disconnect.php');
 
    echo '<tr> <td align=center colspan=5> <input type=submit value="Valider"> </td> </tr>';
    echo '</table>';    
    echo '</form>';

Merci d'avance pour votre aide

Aurevoir