Précédent   Forum des professionnels en informatique > PHP > Langage > Formulaires
Formulaires Forum d'entraide sur les formulaires avec PHP. Avant de poster -> FAQ formulaires, Cours de formulaires et Sources de formulaires
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 18/08/2011, 12h09   #1
Nouveau Membre du Club
 
Femme
Inscription : janvier 2010
Messages : 78
Détails du profil
Informations personnelles :
Sexe : Femme

Informations forums :
Inscription : janvier 2010
Messages : 78
Points : 25
Points : 25
Par défaut pb de radio dans une boucle for

2 soucis pour ma part

1- Le choix par bouton type radio est censé être unique
je ne comprends pas, moi je peux cocher tous les boutons.

2- Je voudrais après avoir cliquer sur un des bouton radio faire une action de suppression mais le traitement ne se fait pas. Il faut peut être utiliser du javascript mais je ne connais pas.

Quelqu'un peut-il m'aider ?

ci-dessous mon code
Code :
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
 
 
<form method="post" action="#" target="" >
<tr>
<th id="label" width="auto">Action N°</th>
<th id="label" width="auto">Date</th>
<th id="label" width="auto">Nature</th>
<th id="label" width="auto">Cabinet</th>
<th id="label" width="auto">Date Dépôt Cab</th>
<th id="label" width="auto">Commentaire</th>
<th id="label" width="auto">Action faite par</th>
<th id="label" width="auto">Supprimer</th>
</tr>
<form method="post" action="#"/>
<?php
 
$id=array();
 
		for ($i=0;$i<count($recap);$i++)
				{
					?>
					<tr >
					<td id=""><?php echo $recap[$i]['actions_id'];?></td>
					<td id=""><?php echo $recap[$i]['actions_dateaction'];?></td>
					<td id=""><?php echo $recap[$i]['actions_nature'];?></td>
					<td id=""><?php if($recap[$i]['actions_cabinet']!='--choisissez--') { echo $recap[$i]['actions_cabinet'];}?></td>
					<td id=""><?php if($donneesact[$i]['actions_cabinet']!='--choisissez--') { echo $recap[$i]['actions_datedepotcab'];}?></td>
					<td id=""><?php echo $recap[$i]['actions_commentairesTPR'];?></td>
					<td id=""><?php echo $recap[$i]['actions_agent'];?></td></form>	
					<td><input name="id[<?php echo $i;?>]" type="radio" value="<?php $id[$i]=$recap[$i]['actions_id'];?>"></input></td>
					</tr>
					<?php
 
				}
				?>
 
</table>
<input align="right" type="submit" value="Supprimer" name="Supp"></input>
 
</form>
 
<?php
if (isset($POST['Supp'])){include ('impayes.php');supaction($id);}
?>				
 
<form method="post"  action="<?php echo "impayes.php?action=accueil&type=$type";?>">
<input type="submit" class="boutonM" name="QUITTER" value="QUITTER"/>
</form>
naroco est déconnecté   Envoyer un message privé Réponse avec citation 01
Vieux 18/08/2011, 12h26   #2
Membre chevronné
 
Homme Taoufiq Ben
Développeur Web
Inscription : mai 2009
Messages : 461
Détails du profil
Informations personnelles :
Nom : Homme Taoufiq Ben
Âge : 25
Localisation : Maroc

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : mai 2009
Messages : 461
Points : 645
Points : 645
1 - parce que ta des noms différent pour chaque input radio, ils doivent avoir le même nom.

2 - Tu pourra faire un form de suppression et l’exécuter avec du javascript

Code :
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
 
<?php
 
$id=array();
 
		for ($i=0;$i<count($recap);$i++)
				{
					?>
					<tr >
					<td id=""><?php echo $recap[$i]['actions_id'];?></td>
					<td id=""><?php echo $recap[$i]['actions_dateaction'];?></td>
					<td id=""><?php echo $recap[$i]['actions_nature'];?></td>
					<td id=""><?php if($recap[$i]['actions_cabinet']!='--choisissez--') { echo $recap[$i]['actions_cabinet'];}?></td>
					<td id=""><?php if($donneesact[$i]['actions_cabinet']!='--choisissez--') { echo $recap[$i]['actions_datedepotcab'];}?></td>
					<td id=""><?php echo $recap[$i]['actions_commentairesTPR'];?></td>
					<td id=""><?php echo $recap[$i]['actions_agent'];?></td></form>	
					<td><input name="id" type="radio" value="<?php $id[$i]=$recap[$i]['actions_id'];?>" onclick="remove('<?php echo $recap[$i]['actions_id'];?>')" /></td>
					</tr>
					<?php
 
				}
				?>
 
</table>
 
 
<script type="text/javascript">
function remove(id)
{
       if (confirm("voulez vous vraiment supprimer"))
       {
              document.getElementById('deleteId').value = id;
              document.deleteForm.submit();
        }
}
</script>
<form name="deleteForm" method="post">
        <input type="hidden" id="deleteId" value="" />
</form>
m4riachi est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/08/2011, 13h20   #3
Nouveau Membre du Club
 
Femme
Inscription : janvier 2010
Messages : 78
Détails du profil
Informations personnelles :
Sexe : Femme

Informations forums :
Inscription : janvier 2010
Messages : 78
Points : 25
Points : 25
Par défaut js

merci pour ta réponse
naroco est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 16h11.


 
 
 
 
Partenaires

Hébergement Web