Bonjour,
Sur un groupe de checkboxes, j'aimerais récupérer la valeur du label (noeud parent d'un checkbox). Sous IE6, ça marche très bien mais FF me ressort un 'undefined'. Il reconnaît le noeud mais pas sa value.
code html:
code 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 <div> <label value="Acoustique" style="display: block;"> <input id="typtrav_1" type="checkbox" onclick="add_typtrav_details(this.id)" name="typtrav[]" value="1"/> Acoustique </label> <label value="Caisse" style="display: block;"> <input id="typtrav_2" type="checkbox" onclick="add_typtrav_details(this.id)" name="typtrav[]" value="2"/> Caisse </label> <label value="GMP" style="display: block;"> <input id="typtrav_3" type="checkbox" onclick="add_typtrav_details(this.id)" name="typtrav[]" value="3"/> GMP </label> <label value="GMP - Boîte" style="display: block;"> <input id="typtrav_4" type="checkbox" onclick="add_typtrav_details(this.id)" name="typtrav[]" value="4"/> GMP - Boîte </label> <label value="GMP - Moteur" style="display: block;"> <input id="typtrav_5" type="checkbox" onclick="add_typtrav_details(this.id)" name="typtrav[]" value="5"/> GMP - Moteur </label> <label value="LAS" style="display: block;"> <input id="typtrav_6" type="checkbox" onclick="add_typtrav_details(this.id)" name="typtrav[]" value="6"/> LAS </label> <label value="Synthèse" style="display: block;"> <input id="typtrav_7" type="checkbox" onclick="add_typtrav_details(this.id)" name="typtrav[]" value="7"/> Synthèse </label> </div>
Je ne comprends pas pourquoi il ne prend pas le value du label..
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 add_typtrav_details = function (id_tt) { if ($(id_tt).checked == true) { var elem = $(id_tt).parentNode; alert(elem); //OK alert(elem.value); // 'undefined' ... } }![]()
Partager