Count checked checkboxes and 2 dropdown values in each function

Count checked checkboxes and 2 dropdown values in each function

I have the code below, and I’m trying to work out how to use count to see if the number of checked checkboxes is more than 1, if so show green tick, if not don’t show, but I cant work out how to count those values.

As you see it below is where I’ve given up trying everything else, and left it at that point to show.

  1. $(document).on('hide.bs.collapse', ".collapse", function () {
        var card = $(this).closest(".card");
        ProcessTickFunctionality(card);
    });
    
    function ProcessTickFunctionality($card) {  
    $card.find('.moduleElement input[type=checkbox]:checked').each(function ()
    { if ($(this)) { console.log("1"); $card.find('.greenTick').css({ "display": "inline" }); } else { console.log("2"); $card.find('.greenTick').css({ "display": "none" }); } });
    }


Once I get that working I then have a further condition to allow the greenTick to show, inside each .moduleElement there a further div with class moduleFrequencyPanel that has two dropdowns and they both also need to have values that are not empty.

There up to 16 .moduleElement div;s so the each function is looping through each one checking to see if the one checkbox in there is checked and both dropdowns have positive values.

For example:

  1. <div class="moduleElement"> <div><input type="checkbox" /></div> <div class="moduleFrequencyPanel"> <select class="moduleFrequencyDropdown"> <option></option> </select> <select class="moduleStartMonthDropdown"> <select> <option></option> <select> </div> </div> 
    

I’ve been on this for ages and simply cant get the whole process to work, as my logic is wrong, could really do with an answer if someone can help.

Thanks in advance

    • Topic Participants

    • info