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 :

integration de script "tout cocher" php / javascript


Sujet :

JavaScript

  1. #1
    Membre r�gulier
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    11
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 11
    Par d�faut integration de script "tout cocher" php / javascript
    Bonjour je voudrais utiliser un script permettant de tout cocher ou tout decocher mes checkbox, le script je l'ai et il fonctionne sur un modele simple, mais je n'arrive cependant pas a l'adapter avec mon code php si quelqu'un pouvait m'aider..

    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
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
      <meta content="text/html; charset=ISO-8859-1"
     http-equiv="content-type">
      <title></title>
     
    <script type="text/javascript">
    <!--
     
    // choix = '0' pour tout décocher
    // choix = '1' pour tout cocher
    // choix = '2' pour inverser la sélection
     
    function GereChkbox(conteneur, choix) {
    var blnEtat=null;
    var Chckbox = document.getElementById(conteneur).firstChild;
    	while (Chckbox!=null) {
    		if (Chckbox.nodeName=="INPUT")
    			if (Chckbox.getAttribute("type")=="checkbox") {
    				blnEtat = (choix=='0') ? false : (choix=='1') ? true : (document.getElementById(Chckbox.getAttribute("id")).checked) ? false : true;
    				document.getElementById(Chckbox.getAttribute("id")).checked=blnEtat;
    			}
    		Chckbox = Chckbox.nextSibling;
    	}
    }
    //-->
    </script>
     
    </head>
    <body>
     
    <?php
     
            require('connectionBD.php');
     
    //-----------------------------------------------------------------------------------------------
    function select_entreprises($code)
    {
    connection();
    $result = mysql_query("select * from entreprises where id_entreprise = $code");
    return $result;
    };
    //-----------------------------------------------------------------------------------------------
      echo"<form action=traitement_doublons2_E.php method=POST>";
     
             if (isset($_POST['bouton'])) 
        {
            for ($i = 0, $c = count($_POST['bouton']); $i < $c; $i++) 
            {
                $res = select_entreprises($_POST['bouton'][$i]);
                            $r = mysql_fetch_array($res);
                echo "
                            <tr>
                            <td><input type='button' value='Tout selectioner' onClick='GereChkbox('div_chck','1');'></td>
                            <td><input type='button' value='Deselectioner' onClick='GereChkbox('div_chck','0');'></td>
                            <div id='div_chck'>
                            <td><input type='radio' name='bouton' value = '".$r[0]."' id='bouton' /></td>
                <td><input type='hidden' name='id_entreprise$i' value = '".$r[0]."' id='id_entreprise$i' /><label for='id_entreprise$i'>$r[0]</label></td>
                <td><input type = 'checkbox' name='checkbox1' id='checkbox1'  value = '".$r[1]."'></input><label for='code_entreprise'>$r[1]</label></td>
                <td><input type = 'checkbox' name='checkbox2' id='checkbox2'  value = '".$r[2]."'><label for='nom'>$r[2]</label></td>
                <td><input type = 'checkbox' name='checkbox3' id='checkbox3'  value = '".$r[3]."'><label for='adr_rue'>$r[3]</label></td>
                <td><input type = 'checkbox' name='checkbox4' id='checkbox4'  value = '".$r[4]."'><label for='adr_compl'>$r[4]</label></td>
                <td><input type = 'checkbox' name='checkbox5' id='checkbox5'  value = '".$r[5]."'><label for='adr_cp'>$r[5]</label></td>
                <td><input type = 'checkbox' name='checkbox6' id='checkbox6'  value = '".$r[6]."'><label for='adr_ville'>$r[6]</label></td>
                <td><input type = 'checkbox' name='checkbox7' id='checkbox7'  value = '".$r[7]."'><label for='adr_pays'>$r[7]</label></td>
                <td><input type = 'checkbox' name='checkbox8' id='checkbox8'  value = '".$r[8]."'><label for='tel'>$r[8]</label></td>
                <td><input type = 'checkbox' name='checkbox9' id='checkbox9'  value = '".$r[9]."'><label for='fax'>$r[8]</label></td>
                            </tr>";
     
            };
         };
      
                    echo' <br /><br />
                              </table>
                              <input type=submit name="mofidier" value="modifier" />
                              </div></form>';
    ?>
     
    </body>
    </html>
    quelqu'un a une id�e ??

    Merci d'avance

  2. #2
    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
    Bonjour,

    Avec ton code, tu auras plusieurs �l�ments avec les m�mes id (exemple le div 'div_chck'). Un Id doit �tre unique dans un document.
    Sinon, montre nous le code html g�n�r� mais pas le php.

    A+.

  3. #3
    Membre r�gulier
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    11
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 11
    Par d�faut
    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
    		<table border=2 ><tr>
    			<td><input type='button' value='Tout selectioner' onClick='GereChkbox('div_chck','1');'></td>
    			<td><input type='button' value='Deselectioner' onClick='GereChkbox('div_chck','0');'></td>
    			<div id='div_chck'>
    			<td><input type='radio' name='bouton' value = '".$r[0]."' id='bouton' /></td>
                <td><input type='hidden' name='id_entreprise$i' value = '".$r[0]."' id='id_entreprise$i' /><label for='id_entreprise$i'>$r[0]</label></td>
                <td><input type = 'checkbox' name='checkbox1' id='checkbox1'  value = '".$r[1]."'></input><label for='code_entreprise'>$r[1]</label></td>
                <td><input type = 'checkbox' name='checkbox2' id='checkbox2'  value = '".$r[2]."'><label for='nom'>$r[2]</label></td>
                <td><input type = 'checkbox' name='checkbox3' id='checkbox3'  value = '".$r[3]."'><label for='adr_rue'>$r[3]</label></td>
                <td><input type = 'checkbox' name='checkbox4' id='checkbox4'  value = '".$r[4]."'><label for='adr_compl'>$r[4]</label></td>
                <td><input type = 'checkbox' name='checkbox5' id='checkbox5'  value = '".$r[5]."'><label for='adr_cp'>$r[5]</label></td>
                <td><input type = 'checkbox' name='checkbox6' id='checkbox6'  value = '".$r[6]."'><label for='adr_ville'>$r[6]</label></td>
                <td><input type = 'checkbox' name='checkbox7' id='checkbox7'  value = '".$r[7]."'><label for='adr_pays'>$r[7]</label></td>
                <td><input type = 'checkbox' name='checkbox8' id='checkbox8'  value = '".$r[8]."'><label for='tel'>$r[8]</label></td>
                <td><input type = 'checkbox' name='checkbox9' id='checkbox9'  value = '".$r[9]."'><label for='fax'>$r[8]</label></td>
    			</tr>";
     <br /><br />
    </table>
    <input type=submit name="mofidier" value="modifier" />
    </div></form>';

  4. #4
    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,

    C'est le code source que tu trouves dans ton navigateur
    Lance la page dans ton navigateur et regarde le code qu'il affiche mas pas le php, c'est �a qu'on veut.

    A+.

  5. #5
    Membre r�gulier
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    11
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 11
    Par d�faut
    j'ai juste sa, le javascript n'apparait pas..

    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
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <FRAMESET BORDER=1>
    <FRAME SRC="frame_centre.html" NAME="bas">
    </FRAMESET>
     
    <head>
      <meta content="text/html; charset=ISO-8859-1"
     http-equiv="content-type">
      <title></title>
    </head>
    <body>
     
    </body>
    </html>

  6. #6
    R�dacteur

    Avatar de Bovino
    Homme Profil pro
    D�veloppeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 55
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activit� : D�veloppeur Web
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Billets dans le blog
    20
    Par d�faut
    Au moins, ton code a une qualit� : il est rigolo

    Bon, en dehors de la syntaxe fantaisiste, � quel moment interviennent tes input
    Parce que j'ai du mal � voir comment, avec une frame en .html tu peux te retrouver avec du code php
    Pas de question technique par MP !
    Tout le monde peut participer � developpez.com, vous avez une id�e, contactez-moi !
    Mes formations video2brain : La formation compl�te sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'int�gration de JSFiddle et CodePen sur le forum

  7. #7
    Membre r�gulier
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    11
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 11
    Par d�faut
    j'affiche mes pages php dans une frame en html, donc sur chaque lien, la page est la meme mais n'affiche pas les meme infos, donc mes input interviennent d�s lors que j'ai cliquer sur un bouton affichant le tableau

  8. #8
    R�dacteur

    Avatar de Bovino
    Homme Profil pro
    D�veloppeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 55
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activit� : D�veloppeur Web
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Billets dans le blog
    20
    Par d�faut
    Ah... d'accord, le code au-dessus n'a donc aucun rapport avec ton probl�me ?
    Pas de question technique par MP !
    Tout le monde peut participer � developpez.com, vous avez une id�e, contactez-moi !
    Mes formations video2brain : La formation compl�te sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'int�gration de JSFiddle et CodePen sur le forum

  9. #9
    Membre r�gulier
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    11
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 11
    Par d�faut
    On m'as demand� d'afficher le code source, donc je l'affiche

  10. #10
    R�dacteur

    Avatar de Bovino
    Homme Profil pro
    D�veloppeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 55
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activit� : D�veloppeur Web
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Billets dans le blog
    20
    Par d�faut
    Ce qu'on te demande, c'est le code HTML g�n�r� qui correspond � ton probl�me, toi tu nous avais donn� le code PHP, mais �a n'a pas beaucoup d'utilit� puisque JavaScript s'ex�cute cot� client, donc sur le code HTML qui a �t� cr��.
    Pas de question technique par MP !
    Tout le monde peut participer � developpez.com, vous avez une id�e, contactez-moi !
    Mes formations video2brain : La formation compl�te sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'int�gration de JSFiddle et CodePen sur le forum

  11. #11
    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
    Citation Envoy� par darkxel Voir le message
    On m'as demand� d'afficher le code source, donc je l'affiche
    Ton php va g�n�rer des code html (tes checkbox), c'est �a ce qu'on veut voir, mais pas n'importe lequel. Si c'est dans un frame, click droite sur le frame et affiche le code source (je ne me souvient pas tr�s bien si c'est comme �a ).

    A+.

  12. #12
    Membre r�gulier
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    11
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 11
    Par d�faut
    click droite sur le frame et affiche le code source (je ne me souvient pas tr�s bien si c'est comme �a
    lorsque je fais sa, sa m'affiche juste sa

    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
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <FRAMESET BORDER=1>
    <FRAME SRC="frame_centre.html" NAME="bas">
    </FRAMESET>
     
    <head>
      <meta content="text/html; charset=ISO-8859-1"
     http-equiv="content-type">
      <title></title>
    </head>
    <body>
     
    </body>
    </html>

  13. #13
    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
    Ce code affiche des checkbox


  14. #14
    Membre r�gulier
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    11
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 11
    Par d�faut
    oui ....

  15. #15
    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
    Installe Firebug et montre nous ce qu'il donne

  16. #16
    Membre r�gulier
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    11
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 11
    Par d�faut
    firebug m'affiche

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
    <title></title>
    </head>
    <frameset border="1">
    <frame name="bas" src="frame_centre.html">
    </frame>
    </frameset>
    </html>

  17. #17
    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

    Essaie d'incr�menter l'id de ton div
    Code php : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
     echo "
    			<tr>
    			<td><input type='button' value='Tout selectioner' onClick='GereChkbox('div_chck".$i."','1');'></td>
    			<td><input type='button' value='Deselectioner' onClick='GereChkbox('div_chck".$i."','0');'></td>
    			<div id='div_chck".$i."'>

    A+.

  18. #18
    Membre r�gulier
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    11
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 11
    Par d�faut re
    re

    j'ai essay� ceci, et malheuresement sa ne fonctionne toujours pas et le javascript n'apparait toujours pas dans firebug..

  19. #19
    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
    As-tu lu le tutoriel sur Firebug pour inspecter le code source

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