IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

un popup de confirmation avant l'execution


Sujet :

Langage PHP

  1. #1
    Membre confirmé
    Femme Profil pro
    Stagiaire
    Inscrit en
    Août 2009
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

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

    Informations forums :
    Inscription : Août 2009
    Messages : 148
    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 : 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
    <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 : 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
    <!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

  2. #2
    Membre émérite
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2009
    Messages
    736
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : Maroc

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

    Informations forums :
    Inscription : Mai 2009
    Messages : 736
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <input name="valider"  type="submit" value="Executer" onclick="if (confirm('Voulez-vous vraiment executer')){testerRadio(r1);}" />

  3. #3
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Par défaut
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    <input name="valider"  type="submit" value="Executer" onclick="if (confirm('Voulez-vous vraiment executer')){ return testerRadio(r1);}" />

    A+.

  4. #4
    Membre confirmé
    Femme Profil pro
    Stagiaire
    Inscrit en
    Août 2009
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

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

    Informations forums :
    Inscription : Août 2009
    Messages : 148
    Par défaut
    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.

  5. #5
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Par défaut
    Tu peux nous montrer ce que tu as fait?

  6. #6
    Membre confirmé
    Femme Profil pro
    Stagiaire
    Inscrit en
    Août 2009
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

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

    Informations forums :
    Inscription : Août 2009
    Messages : 148
    Par défaut
    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 : 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
    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 : 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
     
    <!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,

  7. #7
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Par défaut
    Re,

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

    A+.

  8. #8
    Membre confirmé
    Femme Profil pro
    Stagiaire
    Inscrit en
    Août 2009
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

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

    Informations forums :
    Inscription : Août 2009
    Messages : 148
    Par défaut
    oui merci, mais quand je clique sur cancel il execute le fichier

  9. #9
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Par défaut
    Met le confirm dans le code JS de la fonction testerRadio et dans le onclick tu ne fait que return testerRadio(r1);

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    function testerRadio(r1) { 
    if(confirm("blabla")){
    .....
     
    }
    else {
      return false;
    }
    }

  10. #10
    Membre confirmé
    Femme Profil pro
    Stagiaire
    Inscrit en
    Août 2009
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

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

    Informations forums :
    Inscription : Août 2009
    Messages : 148
    Par défaut
    Merci bc maintenant ca marche

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 24/04/2008, 17h42
  2. Réponses: 1
    Dernier message: 07/05/2007, 23h26
  3. Message confirmation avant fermeture popup
    Par Ant8386 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 19/07/2006, 12h11
  4. Confirmation avant de fermer une fenetre
    Par Dauphin dans le forum C++Builder
    Réponses: 10
    Dernier message: 26/05/2005, 01h27
  5. Réponses: 2
    Dernier message: 03/08/2004, 17h24

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo