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 25/03/2011, 11h39   #1
Futur Membre du Club
 
Femme kaoutar
Stagiaire
Inscription : août 2009
Messages : 148
Détails du profil
Informations personnelles :
Nom : Femme kaoutar
Localisation : France

Informations professionnelles :
Activité : Stagiaire
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : août 2009
Messages : 148
Points : 16
Points : 16
Par défaut un popup de confirmation avant l'execution

Bonjour,

je veux creer un popup pour confirmer l'execution mais j'ai un souci dans ma boutton submit il y a execution d'autre fonction js qui permet de recuperer la valeur de mes radio boutton alors comment je vais faire pour que ma boutton submit executer les deux fonctions js(confirmation et recuperer valeur radio boutton) voila mon code:

code qui permet recuperere la valeur de radio boutton
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
49
50
51
52
53
54
<SCRIPT language="javascript"> 
function testerRadio(r1) { 
for (var i=0; i<r1.length;i++) { 
if (projet1.r1[i].checked) { 
$a=projet1.r1[i].value ;
 
} 
} 
} 
</SCRIPT>
<style type="text/css">
.session {	
	color:#000;
	font:"Arial Black", Gadget, sans-serif;}
</style>
 
<form action="f4.php" method="post">
  <table width="220" border="0">
    <tr>
    <td width="119" height="21"><?php
  @session_start();
?>
      Bonjour,<span class="session"><?php echo'',$_SESSION['login_user'],''; ?></span></td>
    <td width="10"><strong>|</strong></td>
    <td width="77"><h5><a href="deconnexion.php">Deconnexion</a></h5></td>
 
  </tr>
  </table>
  <table width="616" border="0" align="center">
    <tr>
    <td colspan="3" bgcolor="#CCCCCC"><div align="center"><strong>Liste des Fichiers de Configuration</strong></div></td>
  </tr><?php
 
include("connection.php");
//echo('b1');
$id=$_GET['id_projet'];
//echo $id;
 
$q=mysql_query("select * from fichier_config where id_projet=$id ") OR die('Erreur de la requête MySQL'); ?>
 
<tr>
  <td width="216"><strong>Nom fichier de configuration</strong></td>
<td width="116"><strong>Case a cocher</strong></td>
<td width="270"><strong>Description</strong></td></tr> <?php while(
$t=mysql_fetch_array($q)){$i=1; ?> <tr>
    <td bgcolor="#CCCCCC">
 
<?php echo($t['nom_fichier']);?></td>
    <td bgcolor="#CCCCCC"><input type="radio" name="r1" id="r1" value="<?php echo ($t['valeur']); ?>" /></td>
    <td bgcolor="#CCCCCC"><?php echo($t['description']);?></td><input type="hidden" name="confirm" value="oui"/>
 <?php $i++; }?> </tr><tr><td height="26" colspan="2" bgcolor="#FFFFFF"><input name="valider"  type="submit" value="Executer" onclick="testerRadio(r1);" />     </td>
   <td height="26" bgcolor="#FFFFFF"><a href="user.php">&lt;---------</a></td>
 </tr>
</table></form>
code qui permet d'executer formulaire:

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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Outil Import\Export </title>
</head>
 
<body>
<?php
 
if($_REQUEST['confirm']=="oui") 
{ 
$a=$_REQUEST['r1']; 
 
} 
 
 
$d= "D:\CQIET\configuration".$a;
 
 
$file = 'D:\\CQIET\\wamp\\www\\projet_NDS\\koko1.bat';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current= 
"
cd D:\CQIET\sources
 
cqperl main.pl $d D:\CQIET";
// Write the contents back to the file
file_put_contents($file, $current);
require_once("f3.php");
 
?>
<p>&nbsp;</p>
<script language="javascript">
<!-- for(i=0,i<=2,i++){ if(document.2.r1[i].checked){    $a=document.projet2.r1[i].value;  }}</script>
</body>
</html>
Merci d'avance
Miss kouka est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/03/2011, 11h46   #2
Membre chevronné
 
Homme Taoufiq Ben
Développeur Web
Inscription : mai 2009
Messages : 456
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 : 456
Points : 639
Points : 639
Code :
1
2
 
<input name="valider"  type="submit" value="Executer" onclick="if (confirm('Voulez-vous vraiment executer')){testerRadio(r1);}" />
m4riachi est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/03/2011, 18h57   #3
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 126
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 126
Points : 7 270
Points : 7 270
Bonsoir,

Citation:
Envoyé par Miss kouka
for(i=0,i<=2,i++){ if(document.2.r1[i].checked){ $a=document.projet2.r1[i].value;
Il ne faut pas mélanger js et php, php s’exécute du coté serveur et js du coté client.
Citation:
Envoyé par m4riachi
<input name="valider" type="submit" value="Executer" onclick="if (confirm('Voulez-vous vraiment executer')){testerRadio(r1);}" />
Code html :
<input name="valider"  type="submit" value="Executer" onclick="if (confirm('Voulez-vous vraiment executer')){ return testerRadio(r1);}" />

A+.
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/03/2011, 11h02   #4
Futur Membre du Club
 
Femme kaoutar
Stagiaire
Inscription : août 2009
Messages : 148
Détails du profil
Informations personnelles :
Nom : Femme kaoutar
Localisation : France

Informations professionnelles :
Activité : Stagiaire
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : août 2009
Messages : 148
Points : 16
Points : 16
Merci pour vos reponse mais ca marche pas il recupere la valeur de radio boutton et il execute le fichier sans confirmation je ne sais pas pourquoi est vous pouvez m'aider svp.
Miss kouka est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/03/2011, 11h57   #5
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 126
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 126
Points : 7 270
Points : 7 270
Tu peux nous montrer ce que tu as fait?
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/03/2011, 12h28   #6
Futur Membre du Club
 
Femme kaoutar
Stagiaire
Inscription : août 2009
Messages : 148
Détails du profil
Informations personnelles :
Nom : Femme kaoutar
Localisation : France

Informations professionnelles :
Activité : Stagiaire
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : août 2009
Messages : 148
Points : 16
Points : 16
j'ai mis quelque modif et maintenant il m'affiche le message de confirmation mais il ne recupere pas la valeur de radio boutton je ne sais pas pourquoi voila mon code:

code de ma formulaire:

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
49
50
51
52
53
54
55
56
57
58
59
<SCRIPT language="javascript"> 
function testerRadio(r1) { 
for (var i=0; i<r1.length;i++) { 
if (projet1.r1[i].checked) { 
$a=projet1.r1[i].value ;
//alert($a);
//confirm('le fichier de configuration'.$a);
 
} 
} 
} 
</SCRIPT>
<style type="text/css">
.session {	
	color:#000;
	font:"Arial Black", Gadget, sans-serif;}
</style>
 
<form action="f4.php" method="post">
  <table width="220" border="0">
    <tr>
    <td width="119" height="21"><?php
  @session_start();
?>
      Bonjour,<span class="session"><?php echo'',$_SESSION['login_user'],''; ?></span></td>
    <td width="10"><strong>|</strong></td>
    <td width="77"><h5><a href="deconnexion.php">Deconnexion</a></h5></td>
 
  </tr>
  </table>
  <table width="616" border="0" align="center">
    <tr>
    <td colspan="3" bgcolor="#CCCCCC"><div align="center"><strong>Liste des Fichiers de Configuration</strong></div></td>
  </tr><?php
 
include("connection.php");
//echo('b1');
$id=$_GET['id_projet'];
//echo $id;
 
$q=mysql_query("select * from fichier_config where id_projet=$id ") OR die('Erreur de la requête MySQL'); ?>
 
<tr>
  <td width="216"><strong>Nom fichier de configuration</strong></td>
<td width="116"><strong>Case a cocher</strong></td>
<td width="270"><strong>Description</strong></td></tr> <?php while(
$t=mysql_fetch_array($q)){$i=1; ?> <tr>
    <td bgcolor="#CCCCCC">
 
<?php echo($t['nom_fichier']);?></td>
    <td bgcolor="#CCCCCC"><input type="radio" name="r1" id="r1" value="<?php echo ($t['valeur']); ?>" /></td>
    <td bgcolor="#CCCCCC"><?php echo($t['description']);?></td>
 <?php $i++; }?> </tr><tr><td height="26" colspan="2" bgcolor="#FFFFFF">
 
 
 <input name="valider"  type="submit" value="Executer" onclick="if (window.confirm('Voulez-vous vraiment executer')){ testerRadio(r1);}" />     </td>
   <td height="26" bgcolor="#FFFFFF"><a href="user.php">&lt;---------</a></td>
 </tr>
</table></form>
code pour executer le fichier cocher:
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
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Outil Import\Export </title>
</head>
 
<body>
<?php
 
//if($_REQUEST['confirm']=="oui") { 
$a=$_REQUEST['r1']; 
 
$d= "D:\CQIET\configuration".$a;
 
 
$file = 'D:\\CQIET\\wamp\\www\\projet_NDS\\koko1.bat';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current= 
"
cd D:\CQIET\sources
 
cqperl main.pl $d D:\CQIET";
// Write the contents back to the file
file_put_contents($file, $current);
require_once("f3.php");
 
?>
<p>&nbsp;</p>
<script language="javascript">
<!-- for(i=0,i<=2,i++){ if(document.2.r1[i].checked){    $a=document.projet2.r1[i].value;  }}</script>
</body>
</html>
Merci d'avance,
Miss kouka est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/03/2011, 12h43   #7
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 126
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 126
Points : 7 270
Points : 7 270
Re,

Regarde dans le code que j'ai mis, il y a un return avant l'appel de la fonction testerRadio().

A+.
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/03/2011, 12h59   #8
Futur Membre du Club
 
Femme kaoutar
Stagiaire
Inscription : août 2009
Messages : 148
Détails du profil
Informations personnelles :
Nom : Femme kaoutar
Localisation : France

Informations professionnelles :
Activité : Stagiaire
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : août 2009
Messages : 148
Points : 16
Points : 16
oui merci, mais quand je clique sur cancel il execute le fichier
Miss kouka est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/03/2011, 13h09   #9
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 126
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 126
Points : 7 270
Points : 7 270
Met le confirm dans le code JS de la fonction testerRadio et dans le onclick tu ne fait que return testerRadio(r1);

Code :
1
2
3
4
5
6
7
8
9
function testerRadio(r1) { 
if(confirm("blabla")){
.....
 
}
else {
  return false;
}
}
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/03/2011, 13h43   #10
Futur Membre du Club
 
Femme kaoutar
Stagiaire
Inscription : août 2009
Messages : 148
Détails du profil
Informations personnelles :
Nom : Femme kaoutar
Localisation : France

Informations professionnelles :
Activité : Stagiaire
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : août 2009
Messages : 148
Points : 16
Points : 16
Merci bc maintenant ca marche
Miss kouka est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 23h12.


 
 
 
 
Partenaires

Hébergement Web