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

JavaScript Discussion :

Redirectionvers une page PHP


Sujet :

JavaScript

  1. #1
    Futur Membre du Club
    Inscrit en
    Février 2005
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 4
    Par défaut Redirectionvers une page PHP
    Bonjour,

    Je précise que j'ai bien cherché avant, ca fait deux jours que je suis dessus sans succès.

    J'ai un tableau avec des enregistrement provenant de MySQL.

    devant chaque enregistrement, j'ai mis un bouton radio pour sélection ma ligne et pouvoir exécuter un action sur cet enregistrement c'est à dire modification de l'enregistrement et supression.

    J'arrive bien à récupérer la ligne sélectionnée dans mon tableau, mais je n'arrive pas à faire la redirection vers ma page PHP pour accéder à mon formulaire de modification.

    Ci joint le code pour accéder à ma page php qui supprime l'enregistrement

    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 supprimer() {
        var m=0;
        var id=0;
            for (i=0;i<15;i++) {
                if (document.forms.le.choix[i].checked==true) {
                    m=i;
                    id=document.forms.le.choix[i].value;
                    document.location.href="includes/s_enquete.php?ID="+id;
     
                    break;
                }
            } 
    }
    J'ai essayer document.location.href et windowd.location sans succès.

    Merci d'avance de votre aide.

  2. #2
    Membre émérite Avatar de Sheriff
    Inscrit en
    Octobre 2004
    Messages
    608
    Détails du profil
    Informations forums :
    Inscription : Octobre 2004
    Messages : 608
    Par défaut
    salut !
    est-ce que ça te renvoie une erreur ?
    est ce que ça t'ouvre une page invalide ?
    j'aimerais avoir plus de précisions...
    @+

  3. #3
    Futur Membre du Club
    Inscrit en
    Février 2005
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 4
    Par défaut testbdfqsd
    Bonjour,

    Non ca ne me donne pas d'erreur dans la console Firefox.

    Et ca me renvoie nul part, ma page se réactualise uniquement.

    Les script de la pages :
    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
    <script type="text/javascript">
    <!--
    function MM_reloadPage(init) {  //reloads the window if Nav4 resized
    if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
    else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
    }
    MM_reloadPage(true);
     
    function modifier() {
        alert ('Modifier');
    }
     
    function supprimer() {
        var m=0;
        var id=0;
            for (i=0;i<15;i++) {
                if (document.forms.le.choix[i].checked==true) {
                    m=i;
                    id=document.forms.le.choix[i].value;
                    window.document.location="includes/s_enquete.php?ID="+id;
                    break;
                }
            } 
    }
     
     
    //-->
    </script>
    Mon tableau :

    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
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
                        <tbody>
                          <tr>
                            <td class="maincontent" valign="top"><div class="componentheading"> Liste des enqu&ecirc;tes en cours</div>
                              <form action="index.php" method="post" name="le">
                              <table class="contentpane" align="center" border="0" cellpadding="4" cellspacing="0" width="100%">
                              <tbody>
                                <tr>
                                  <td><table border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tbody>
                              <form name="le">
                                <!--Affichage des entêtes du tableau-->
                                <tr>
                                    <td width="10" class="sectiontableheader">&nbsp;</td>
                                    <td class="sectiontableheader" width="30" align="center">N&deg;</td>
                                    <td class="sectiontableheader" width="70" align="center">Date</td>
                                    <td class="sectiontableheader" width="90" align="center">Matricule</td>
                                    <td class="sectiontableheader" width="200"align="center" >Nom / Pr&eacute;nom </td>
                                    <td class="sectiontableheader" width="70" align="center">Date R&eacute;a. </td>
                                    <td class="sectiontableheader" width="70" align="center">Date Fin </td>
                                    <td class="sectiontableheader" width="80" align="center">Demandeur</td>
                                    <td class="sectiontableheader" width="80"align="center">Controleur</td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="1"></td>
                                    <td align="center">1</td>
                                    <td align="center">2006-05-01</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">Bougerolle Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="2"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="3"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="4"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="5"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="6"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="7"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="8"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="9"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="10"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="11"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="12"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="13"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="14"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                                <tr class="sectiontableentry1">
                                    <td align="center" width="33"><input type="radio" name="choix" value="15"></td>
                                    <td align="center"></td>
                                    <td align="center">2006-05-15</td>
                                    <td align="center">1790321054024</td>
                                    <td align="center">BOUGEROLLE Emmanuel</td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                    <td align="center"></td>
                                  </tr>
                              </form>
                        </tbody>
                      </table>

  4. #4
    Membre émérite Avatar de Sheriff
    Inscrit en
    Octobre 2004
    Messages
    608
    Détails du profil
    Informations forums :
    Inscription : Octobre 2004
    Messages : 608
    Par défaut
    j'ai testé ton petit code js sous ie, ça marche...
    ça doit être le navigateur.
    essaie un peu le
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    window.open('includes/s_enquete.php?id='+id,'_self')
    @+

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    91
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 91
    Par défaut
    Normalement le "window.open" ouvre bien ta page mais dans une nouvelle fenêtre.
    Pour réutiliser la même fenêtre et être redirigé, il me semble qu'il s'agit de :
    "window.location.replace"

  6. #6
    Futur Membre du Club
    Inscrit en
    Février 2005
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 4
    Par défaut Ca fonctionne mais !
    Bon ca fonctionne avec le code suivant, merci bien pour vos réponses.

    Mais il mereste un problème.

    Imaginons qu'après supression il ne me reste plus qu'un ligne dans mon tableau et donc un seul bouton radion.

    Ben se code ne marche plus. A priori si il y a un seul bouton il ne renvoie pas un tableau d'indices et donc document.forms.le.choix[i].checked==true ne fonctionne pas. J'arrive à accéder à cette propriété en faisant document.forms.le.choix.checked==true.

    Il y a t'il un moyen de compter le nombre de bouton radio dan smon formulaire ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
            for (i=0;i<15;i++) {
            alert(i);
                if (document.forms.le.choix[i].checked==true) {
                    m=i;
                    id=document.forms.le.choix[i].value;
                    window.open('http://localhost/portail/_controle/includes/s_enquete.php?ID='+id,'_self');
                    break;
                }
            }

  7. #7
    Membre confirmé
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    91
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 91
    Par défaut
    je ne suis pas sur mais un getElementsByName("choix") devrait te renvoyer un tableau contenant tous les éléments de ce nom. Ensuite, avec un getElementsByName("choix").length tu as le nombre total.

  8. #8
    Futur Membre du Club
    Inscrit en
    Février 2005
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 4
    Par défaut
    Finalement, j'ai trouver plus simple sur ce super forum, avec un peu de temps on fini par y arriver.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    function supprimer() {
        var id=0;
        var aCheckList = document.getElementsByName('choix');
     
        for(iLoop=0;iLoop<aCheckList.length;iLoop++){
            if(aCheckList[iLoop].checked==true){
                id=aCheckList[iLoop].value;
                window.open('http://localhost/portail/_controle/includes/s_enquete.php?ID='+id,'_self');
                window.reload();
            }
        }
    }
    Il a juste un léger soucis, mon tableau HTML n'est pas réactualisé.

    J'ai essayé avec windows.reload(); sans succès.

Discussions similaires

  1. inserer une page php externe dans une page JSP
    Par vrossi59 dans le forum Servlets/JSP
    Réponses: 11
    Dernier message: 05/07/2005, 16h25
  2. Réponses: 11
    Dernier message: 11/03/2005, 17h41
  3. problème debodybackground dans une page php
    Par bertrand_declerck dans le forum Balisage (X)HTML et validation W3C
    Réponses: 4
    Dernier message: 04/02/2005, 22h39
  4. Boutons Radios qui charge une page php différente
    Par nebule dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 18/11/2004, 15h25
  5. connection a mssql a partir d'une page php
    Par jean_marc dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 26/11/2003, 14h24

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