• We are using woo and the woo filter for products. I hooked it up on this test page and I am trying to change images on chekckbox of color… still in early testing.

    at this point the code, right now as testing on the page, you check the color box and in console it will write the value.

    here is my test on codepen:

    https://codepen.io/hjmoore420/pen/YzwgGRN

    on codepen the HTML is rendered code from the Filter test page.

    it is working there. I did find some issues on the live page, but have fixed them. At this point I am just trying to get the value of the checkbox to write to the console.

    I went to debug and found not issues, changed themes and it did not work. the code is just straight JS nothing crazy.

    Any help will be appreciated.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m not 100% sure, but I think there is another event listener on the checkboxes that is superseding yours. (the one that invokes the product filter) You may need to remove that one in order to see yours work.

    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 4 years, 7 months ago by bcworkz. Reason: code fixed
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘JS not working on page’ is closed to new replies.