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 :

[DOM] un tableau de checkbox


Sujet :

JavaScript

Vue hybride

Message pr�c�dent Message pr�c�dent   Message suivant Message suivant
  1. #1
    Membre �clair�
    Inscrit en
    Avril 2007
    Messages
    233
    D�tails du profil
    Informations personnelles :
    �ge : 40

    Informations forums :
    Inscription : Avril 2007
    Messages : 233
    Par d�faut [DOM] un tableau de checkbox
    salut,

    je veux q'une fois je coche un checkbox, toute la ligne de checkbox prend une couleur, �a veux dire que tous le td o� se trouve ce checkbox prend une couleur diff�rente..

    Merci

  2. #2
    R�dacteur/Mod�rateur

    Avatar de SpaceFrog
    Homme Profil pro
    D�veloppeur Web Php Mysql Html Javascript CSS Apache - Int�grateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 659
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 75
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activit� : D�veloppeur Web Php Mysql Html Javascript CSS Apache - Int�grateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 659
    Billets dans le blog
    1
    Par d�faut
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    onmouseup="this.parentNode.parentNode.style.backgroundColor=(this.checked)?'red':'white';"
    Ma page Developpez - Mon Blog Developpez
    Pr�sident du CCMPTP (Comit� Contre le Mot "Probl�me" dans les Titres de Posts)
    Deux r�gles du succ�s: 1) Ne communiquez jamais � quelqu'un tout votre savoir...
    Votre post est r�solu ? Alors n'oubliez pas le Tag

    Venez sur le Chat de D�veloppez !

  3. #3
    Membre �clair�
    Inscrit en
    Avril 2007
    Messages
    233
    D�tails du profil
    Informations personnelles :
    �ge : 40

    Informations forums :
    Inscription : Avril 2007
    Messages : 233
    Par d�faut
    S'il vous j'aimerai quelque chose de plus sinificative

    Merci d'avance

  4. #4
    Expert confirm�
    Avatar de javatwister
    Homme Profil pro
    danseur
    Inscrit en
    Ao�t 2003
    Messages
    3 684
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activit� : danseur

    Informations forums :
    Inscription : Ao�t 2003
    Messages : 3 684
    Par d�faut
    oui c'est vrai t'abuses, l�!

  5. #5
    R�dacteur/Mod�rateur

    Avatar de SpaceFrog
    Homme Profil pro
    D�veloppeur Web Php Mysql Html Javascript CSS Apache - Int�grateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 659
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 75
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activit� : D�veloppeur Web Php Mysql Html Javascript CSS Apache - Int�grateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 659
    Billets dans le blog
    1
    Par d�faut
    Pfff ... ils ne font vraiment plus aucun effort

    Bon je suis de bonne humeur et voil� ce que �a peut donner :

    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
    <script type='text/javascript'>
     
    function highlightLine(obj){
     
     setTimeout(function(){ if(obj.parentNode.parentNode.colored==undefined){obj.parentNode.parentNode.colored=0;}
     							obj.parentNode.parentNode.colored+=(obj.checked)?1:-1;
     							if (obj.parentNode.parentNode.colored==0){obj.parentNode.parentNode.style.backgroundColor='white';
                                                return true;} 
                            else{obj.parentNode.parentNode.style.backgroundColor=((obj.checked=='false')&&(obj.backgroundColor!='red'))?'white':'red';}
                            	}
                            	,100)
    	}
    	</script>
    </head>
     
    <body>
     
    <table border="1" width="100%">
      <tr>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="12%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
      </tr>
      <tr>
        <tr>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="12%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
      </tr>
      </tr>
      <tr>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="12%">&nbsp;</td>
      </tr>
    </table>
     
    </body>
     
    </html>
    arf juste un detail � regler si click trop rapides ...
    en fait on doit pouvoir virer le setTimeout
    Ma page Developpez - Mon Blog Developpez
    Pr�sident du CCMPTP (Comit� Contre le Mot "Probl�me" dans les Titres de Posts)
    Deux r�gles du succ�s: 1) Ne communiquez jamais � quelqu'un tout votre savoir...
    Votre post est r�solu ? Alors n'oubliez pas le Tag

    Venez sur le Chat de D�veloppez !

  6. #6
    Membre �clair�
    Inscrit en
    Avril 2007
    Messages
    233
    D�tails du profil
    Informations personnelles :
    �ge : 40

    Informations forums :
    Inscription : Avril 2007
    Messages : 233
    Par d�faut
    Merci bcp SpaceFrog, au fait je ne voulais pas tout le code, juste des petites explications parce que DOM c'est pas mon point fort!!

    Merci, esp�rant que tu resteras tjrs en bonne humeur.

  7. #7
    R�dacteur/Mod�rateur

    Avatar de SpaceFrog
    Homme Profil pro
    D�veloppeur Web Php Mysql Html Javascript CSS Apache - Int�grateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 659
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 75
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activit� : D�veloppeur Web Php Mysql Html Javascript CSS Apache - Int�grateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 659
    Billets dans le blog
    1
    Par d�faut
    Bon voil� le souci des doubles et triples et multiclicks r�solu :

    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
    <script type='text/javascript'>
    var clicked=false;
    function highlightLine(obj){
     if(clicked){return true;}
     clicked=true;
     if(obj.parentNode.parentNode.colored==undefined){obj.parentNode.parentNode.colored=0;}
     obj.parentNode.parentNode.colored+=(obj.checked)?1:-1;
     if (obj.parentNode.parentNode.colored==0){obj.parentNode.parentNode.style.backgroundColor='white';
                                               clicked=false;
                                                return true;} 
     else{obj.parentNode.parentNode.style.backgroundColor=((obj.checked=='false')&&(obj.backgroundColor!='red'))?'white':'red';}
     clicked=false;
                            	}
     
    	</script>
    </head>
     
    <body>
     
    <table border="1" width="100%">
      <tr>
        <td width="11%"><input type="checkbox" onmousedown="highlightLine(this)" ondblclick='return false;'></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)" ondblclick='return false;'></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)" ondblclick='return false;'></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)" ondblclick='return false;'></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="12%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
      </tr>
      <tr>
        <tr>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="11%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
        <td width="12%"><input type="checkbox" onmouseup="highlightLine(this)"></td>
      </tr>
      </tr>
      <tr>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="11%">&nbsp;</td>
        <td width="12%">&nbsp;</td>
      </tr>
    </table>
    Ma page Developpez - Mon Blog Developpez
    Pr�sident du CCMPTP (Comit� Contre le Mot "Probl�me" dans les Titres de Posts)
    Deux r�gles du succ�s: 1) Ne communiquez jamais � quelqu'un tout votre savoir...
    Votre post est r�solu ? Alors n'oubliez pas le Tag

    Venez sur le Chat de D�veloppez !

Discussions similaires

  1. recuperer un tableau de checkbox
    Par jojo22222 dans le forum G�n�ral JavaScript
    R�ponses: 1
    Dernier message: 18/05/2006, 08h43
  2. R�cup�rer un tableau de checkbox !
    Par SunSyS dans le forum G�n�ral JavaScript
    R�ponses: 5
    Dernier message: 27/02/2006, 14h36
  3. Tableau de checkbox
    Par rdams dans le forum G�n�ral JavaScript
    R�ponses: 1
    Dernier message: 29/08/2005, 17h31
  4. r�cup�rer un tableau de checkbox
    Par mr.t dans le forum ASP
    R�ponses: 3
    Dernier message: 05/04/2005, 16h11
  5. Style d'une ligne d'un tableau et Checkbox
    Par echecetmat dans le forum G�n�ral JavaScript
    R�ponses: 3
    Dernier message: 25/01/2005, 15h03

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