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
|
//Toggle de la liste
var obj, selectVal,index_parent, string = '';
$(".multiple-choix").on("click", ".hida1", function() {
$(".mutliSelect1 ol").not($(".mutliSelect1 ol", $(this).parent())).slideUp('500');
$(".mutliSelect1 ol", $(this).parent()).slideToggle('500');
})
//Reporter valeur directement après on "click"
.on("change", "input[type='checkbox']", function() {
index_parent = $(this).parents("dl").index(".multiple-choix");
obj = $(this).parents('.multiple-choix').find(".hida1 span");
selectVal = parseInt(index_parent + 1);
string = obj.text();
$(this).each(function() {
//pour chaque checkbox dont la valeur est true
if ($(this).is(':checked')) {
if (string.indexOf('Select ' + selectVal) == 0) {
string = string.replace("Select " + selectVal, "") + $(this).val() + ", ";
} else if (string.indexOf('Select ' + selectVal) < 0) {
string += $(this).val() + ", ";
}
} else {
string = string.replace($(this).val() + ", ", "");
}
if (string == '') {
string = 'Select ' + selectVal;
}
obj.text(string);
/*console.log(" index_parent :" + index_parent + " nodeName :" + obj.get(0).nodeName + " selectVal :" + selectVal);*/
});
}); |
Partager