Bonjour,
Je souhaite rajouter un bouton type="checkbox" qui me permet de rendre actif ou non un bouton envoyer. Ma difficulté est que je génère une liste contenu de ma page à partir d'une base sql, je ne sais pas comment gérer la gestion individuelle des boutons. Comment puis-je gérer l'id "submite" pour chaque ligne ?
Voici mon code pour la page avec mon script javascript :
Merci pour votre aide


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function affiche_bouton() 
{ 
var isChecked=false;
for (i=0; i<document.getElementsByTagName("input").length; i++)
if (document.getElementsByTagName("input")[i].type=="checkbox")
if (document.getElementsByTagName("input")[i].checked)
isChecked=true;
if (isChecked)
{
document.getElementById('submite').disabled='';
} else {
document.getElementById('submite').disabled='disabled';
}
}


Code html : 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
53
54
55
56
<div id="content">
 
          <div id="contenu">
 
            <h1 align="center" style="color: #155A97;font-size: 16px;font-family: Arial, Helvetica, sans-serif;border:1px solid #AFD3F3;background-color:#FFFFFF;">Liste</h1>
 
 
            <p style="color: #155A97;font-size: 12px;font-family: Arial, Helvetica, sans-serif;border:0px solid #AFD3F3;background-color:#FFFFFF;">&nbsp;</p>
            <table width="950" border="0" cellspacing="2" cellpadding="2" align="left" style="font-family:Arial; font-size:12px; color:#155a97;padding: 2px;border:1px solid #AFD3F3;background-color:#FFFFFF;" valign=top>
 
                <tr>
                    <th colspan="3" bgcolor="#FAFCFE" ><div align="left">
                      <div align="left" style="color: #9732B2;font-size: 12px;font-family: Arial, Helvetica, sans-serif;padding-left:5px;padding-bottom:0px;padding-top:0px;">x</div>
                    </div>                    </th>
                    <th width="5" rowspan="2" bgcolor="#ffffff" style="color: #ffffff;font-size: 12px;font-family: Arial, Helvetica, sans-serif;padding-left:0px;padding-bottom:0px;padding-top:0px;">&nbsp;</th>
                </tr>
                <tr>
                  <th width="116" bgcolor="#9732B2" style="color: #ffffff;font-size: 12px;font-family: Arial, Helvetica, sans-serif;padding-left:5px;padding-bottom:0px;padding-top:0px;"><div align="left">CODE </div></th>
                  <th width="326" bgcolor="#9732B2" style="color: #ffffff;font-size: 12px;font-family: Arial, Helvetica, sans-serif;padding-left:5px;padding-bottom:0px;padding-top:0px;"><div align="left">Titre de l'emailing</div></th>
                  <th width="83" bgcolor="#9732B2" style="color: #ffffff;font-size: 12px;font-family: Arial, Helvetica, sans-serif;padding-left:5px;padding-bottom:0px;padding-top:0px;">Envoyer</th>
              </tr>
 
 
 
 
 
 
 
 
 
                <?php
                    
                    include('connect.php');
                    
                    $req = mysql_query("SELECT * FROM emailing WHERE `code_emailing` LIKE '%F/E%' ORDER BY date_envoi");
                    while ($data = mysql_fetch_assoc($req)) :
                ?>
 
                <tr>
                    <td valign=top style="font-family:Arial; font-size:12px; color:#155a97;padding: 5px;border-bottom:1px solid #AFD3F3;background-color:#F4E7F8;"><?php echo $data['code_emailing']; ?></td>
                    <td valign=top style="font-family:Arial; font-size:12px; color:#155a97;padding: 5px;border-bottom:1px solid #AFD3F3;background-color:#F4E7F8;"><?php echo $data['titre']; ?></td>
                    <td style="font-family:Arial; font-size:12px; color:#155a97;padding: 5px;border-bottom:1px solid #AFD3F3;background-color:#FAFCFE;" valign=top>
                    <input type="checkbox" name="checkbox" id="checkbox" onClick="affiche_bouton()" />
                    <a onClick="return confirm('Souhaitez-vous vraiment lancer envoi des mails ?');" href="envoiEmail.php?page=<?php echo $data['id']; ?>" >
 <input type="submit" name="button" value="ENVOI" id="submite" disabled="disabled" style="font-family:Arial; font-size:12px; padding: 2px;"/></a>                    </td>
 
                    <td style="font-family:Arial; font-size:12px; color:#155a97;padding: 0px;border-bottom:0px solid #AFD3F3;background-color:#Ffffff;" valign=top>&nbsp;</td>
                </tr>
 
                <?php endwhile; ?>
            </table>
 
 
 
          </div>
        </div>