lundi 6 juin 2016

JS - Filter Data - Using Push & Splice

If I have 3 sets of checkboxes (each set contains N number of checkboxes), and the checkboxes are pulling from the same data set, how do I incorporate an "AND" functionality so that if you select an item or 2 from the 1st set of checkboxes and then select a checkbox or 2 from the 2nd set of checkboxes, only the items that match are displayed...essentially each checkbox (per set of checkboxes) is a filter?

var disar = new Array();

function cboxFilet(actionAdd, idList) {

    if (actionAdd == true) {

        for (var r in idList) {
            disar.push(idList[r]);
        }
        alert("ADD: " + disar);
    } else {

        for (r in idList) {
            var loc = disar.indexOf(idList[r]);
            disar.splice(loc, 1);
        }
        alert("REMOVE: " + disar);
    }

}




Aucun commentaire:

Enregistrer un commentaire