Bonjour à tous,
j'ai réalisé une interface avec des boutons à choix multiple. J'ai groupé les boutons par catégorie. et sur chaque groupe la première case permet de cocher tous les éléments du groupe c'est à dire si je coche ce cette case toutes les autres doivent être cochées. Pour le moment ça passe, maintenant je veux faire l'inverse c'est à dire si l'une des cases est décochée la case Tout (qui permet de tout cocher) doit être décochée. C'est là que tout coince![]()
Code HTML:
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
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 <div class="portlet-body"> <div class="table-responsive"> <table class="table table-striped table-bordered table-hover"> <thead> <tr> <th>Configuration </th> <th> Article </th> <th> Catégorie article </th> <th> Unité article </th> <th> Règle de réapprovisionnement </th> <th> Mouvement </th> </tr> </thead> <tbody> <tr> <td> <div class="mt-checkbox-list config_priv"> <label class="mt-checkbox mt-checkbox-outline"> <input name="config_priv_all" type="checkbox" class="tout" id="check_all_config" value="4">Tout <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="config_priv" type="checkbox" class ="checked_checkbox" id="add_config" value="add_config"> Ajouter <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="config_priv" type="checkbox" class ="checked_checkbox" id="update_config" value="2">Modifier <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="config_priv" type="checkbox" class ="checked_checkbox" value="list_config">Lister <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="config_priv" type="checkbox" class ="checked_checkbox" value="delete_config">Supprimer <span></span> </label> </div> </td> <td> <div class="mt-checkbox-list priv_article"> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv" class="tout" type="checkbox" value="userT">Tout <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_A" type="checkbox" class ="checked_checkbox" value="userA"> Ajouter <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_M" type="checkbox" class ="checked_checkbox" value="userM">Modifier <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_L" type="checkbox" class ="checked_checkbox" value="userL">Lister <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_S" type="checkbox" class ="checked_checkbox" value="userS">Supprimer <span></span> </label> </div> </td> <td> <div class="mt-checkbox-list priv_categorie"> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv" class="tout" class ="checked_checkbox" type="checkbox" value="userT">Tout <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_A" type="checkbox" class ="checked_checkbox" value="userA"> Ajouter <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_M" type="checkbox" class ="checked_checkbox" value="userM">Modifier <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_L" type="checkbox" class ="checked_checkbox" value="userL">Lister <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_S" type="checkbox" class ="checked_checkbox" value="userS">Supprimer <span></span> </label> </div> </td> <td> <div class="mt-checkbox-list priv_unite"> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv" class="tout" type="checkbox" value="userT">Tout <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_A" type="checkbox" class ="checked_checkbox" value="userA"> Ajouter <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_M" type="checkbox" class ="checked_checkbox" value="userM">Modifier <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_L" type="checkbox" class ="checked_checkbox" value="userL">Lister <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_S" type="checkbox" class ="checked_checkbox" value="userS">Supprimer <span></span> </label> </div> </td> <td> <div class="mt-checkbox-list priv_regle"> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv" class="tout" class ="checked_checkbox" type="checkbox" value="userT">Tout <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_A" type="checkbox" class ="checked_checkbox" value="userA"> Ajouter <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_M" type="checkbox" class ="checked_checkbox" value="userM">Modifier <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_L" type="checkbox" class ="checked_checkbox" value="userL">Lister <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_S" type="checkbox" class ="checked_checkbox" value="userS">Supprimer <span></span> </label> </div> </td> <td> <div class="mt-checkbox-list priv_mouvement"> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv" class="tout" type="checkbox" value="userT">Tout <span></span> </label> </br> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_A" type="checkbox" class ="checked_checkbox" value="userA"> Ajouter <span></span> </label> </br> <!-- <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_M" type="checkbox" class ="checked_checkbox" value="userM">Modifier <span></span> </label> </br> --> <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_L" type="checkbox" class ="checked_checkbox" value="userL">Lister <span></span> </label> </br> <!-- <label class="mt-checkbox mt-checkbox-outline"> <input name="droit_priv_S" type="checkbox" class ="checked_checkbox" value="userS">Supprimer <span></span> </label> --> </div> </td> </tr> </tbody> </table> </div> </div>
Coté JavaScript :
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 <script type="text/javascript"> $(document).ready(function(){ $(".tout").on("change", function(e){ var checked = $(this).parent().parent().parent().parent().find(".checked_checkbox"); var tout = $(this).parent().parent().parent().parent().find(".tout"); if(!$(tout).is(':checked')){ $(checked).prop('checked', true); $(checked).trigger("click"); }else{ $(checked).prop('checked',false); $(checked).trigger("click"); } $(tout).not(this).prop('checked', false); }); $("#all_priv").on("change", function(e){ var tout = $(this).parent().parent().parent().parent().parent().find(".tout"); if(!$("#all_priv").is(':checked')){ $(tout).prop('checked', true); $(tout).trigger("click"); }else{ $(tout).prop('checked',false); $(tout).trigger("click"); } }) }) </script>
Partager