Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter hjmoore420

    (@hjmoore420)

    The end code was mostly what I started with but I changed the addEventListener to click and it worked well:

    function getSelectedCheckboxValues(name) {
        const checkboxes = document.querySelectorAll(<code>input[name=&quot;${name}&quot;]:checked</code>);
        let values = [];
        checkboxes.forEach((checkbox) => {
            values.push(checkbox.value);
          
        });
        return values;
    }
    
    document.body.addEventListener('click', function (e) {
      console.log(getSelectedCheckboxValues('colors-check'));
      });
    • This reply was modified 5 years, 9 months ago by bcworkz. Reason: code fixed
Viewing 1 replies (of 1 total)