Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > JavaScript
JavaScript Forum programmation JavaScript. Lire : Cours JavaScript, FAQ JavaScript, Toutes les FAQ JavaScript et Sources JavaScript
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 14/06/2011, 11h32   #1
 
Inscription : juin 2011
Messages : 11
Détails du profil
Informations forums :
Inscription : juin 2011
Messages : 11
Points : -1
Points : -1
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 :
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
darkxel est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 11h42   #2
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 128
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 128
Points : 7 269
Points : 7 269
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+.
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 11h45   #3
 
Inscription : juin 2011
Messages : 11
Détails du profil
Informations forums :
Inscription : juin 2011
Messages : 11
Points : -1
Points : -1
Code html :
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>';
darkxel est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 11h57   #4
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 128
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 128
Points : 7 269
Points : 7 269
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+.
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 12h02   #5
 
Inscription : juin 2011
Messages : 11
Détails du profil
Informations forums :
Inscription : juin 2011
Messages : 11
Points : -1
Points : -1
j'ai juste sa, le javascript n'apparait pas..

Code html :
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>
darkxel est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 13h51   #6
Responsable Développement Web

 
Avatar de Bovino
 
Homme Didier Mouronval
Développeur Web
Inscription : juin 2008
Messages : 13 807
Détails du profil
Informations personnelles :
Nom : Homme Didier Mouronval
Âge : 41
Localisation : France, Gironde (Aquitaine)

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

Informations forums :
Inscription : juin 2008
Messages : 13 807
Points : 35 797
Points : 35 797
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 !
Vous possédez un blog et aimeriez diffuser vos billets sur le forum, 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
Bovino est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 14h55   #7
 
Inscription : juin 2011
Messages : 11
Détails du profil
Informations forums :
Inscription : juin 2011
Messages : 11
Points : -1
Points : -1
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
darkxel est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 15h05   #8
Responsable Développement Web

 
Avatar de Bovino
 
Homme Didier Mouronval
Développeur Web
Inscription : juin 2008
Messages : 13 807
Détails du profil
Informations personnelles :
Nom : Homme Didier Mouronval
Âge : 41
Localisation : France, Gironde (Aquitaine)

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

Informations forums :
Inscription : juin 2008
Messages : 13 807
Points : 35 797
Points : 35 797
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 !
Vous possédez un blog et aimeriez diffuser vos billets sur le forum, 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
Bovino est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 15h12   #9
 
Inscription : juin 2011
Messages : 11
Détails du profil
Informations forums :
Inscription : juin 2011
Messages : 11
Points : -1
Points : -1
On m'as demandé d'afficher le code source, donc je l'affiche
darkxel est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 15h19   #10
Responsable Développement Web

 
Avatar de Bovino
 
Homme Didier Mouronval
Développeur Web
Inscription : juin 2008
Messages : 13 807
Détails du profil
Informations personnelles :
Nom : Homme Didier Mouronval
Âge : 41
Localisation : France, Gironde (Aquitaine)

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

Informations forums :
Inscription : juin 2008
Messages : 13 807
Points : 35 797
Points : 35 797
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 !
Vous possédez un blog et aimeriez diffuser vos billets sur le forum, 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
Bovino est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 15h20   #11
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 128
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 128
Points : 7 269
Points : 7 269
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+.
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 15h27   #12
 
Inscription : juin 2011
Messages : 11
Détails du profil
Informations forums :
Inscription : juin 2011
Messages : 11
Points : -1
Points : -1
Citation:
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 :
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>
darkxel est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 15h34   #13
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 128
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 128
Points : 7 269
Points : 7 269
Ce code affiche des checkbox

andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 15h37   #14
 
Inscription : juin 2011
Messages : 11
Détails du profil
Informations forums :
Inscription : juin 2011
Messages : 11
Points : -1
Points : -1
oui ....
darkxel est déconnecté   Envoyer un message privé Réponse avec citation 01
Vieux 14/06/2011, 15h44   #15
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 128
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 128
Points : 7 269
Points : 7 269
Installe Firebug et montre nous ce qu'il donne
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2011, 16h29   #16
 
Inscription : juin 2011
Messages : 11
Détails du profil
Informations forums :
Inscription : juin 2011
Messages : 11
Points : -1
Points : -1
firebug m'affiche

Code :
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>
darkxel est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/06/2011, 09h47   #17
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 128
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 128
Points : 7 269
Points : 7 269
Re

Essaie d'incrémenter l'id de ton div
Code php :
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+.
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/06/2011, 10h07   #18
 
Inscription : juin 2011
Messages : 11
Détails du profil
Informations forums :
Inscription : juin 2011
Messages : 11
Points : -1
Points : -1
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..
darkxel est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/06/2011, 11h12   #19
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 128
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 128
Points : 7 269
Points : 7 269
As-tu lu le tutoriel sur Firebug pour inspecter le code source
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 05h09.


 
 
 
 
Partenaires

Hébergement Web