Avatar of M A
M A
Flag for United States of America asked on

Automate filter in Opencart.

Automate filter in Opencart default template.
<script type="text/javascript">
$(document).ready(function() {
    // hide the "submit" button
    $('#button-filter').hide();

    // bind onChange event to the checkboxes
    $('.click_checkbox_manufacturers-filter').live('change', function() {
        filter = [];

        $('.box-filter input[type=\'checkbox\']:checked').each(function(element) {
            filter.push(this.value);
        });

        window.location = '<?php echo $action; ?>&filter=' + filter.join(',');
    });
});
//--></script>

Open in new window


I replaced with this code but it hide the refine search button but it is not giving the right result.
Now the refine button is hidden but not getting the right result. I want to update the filter when I tick the tickbox.
Capture1.JPG
Is there anyone who can guide me to get the filter on check box event.
PHPJavaScriptScripting LanguagesMySQL Server* Opencart

Avatar of undefined
Last Comment
M A

8/22/2022 - Mon
Leonidas Dosas

$(document).ready(function() {
    // hide the "submit" button
    
    var filter = [];
    // I suggest you to change the live() method to on
    $('.click_checkbox_manufacturers-filter').on('change', function() {
         filter=[];
         $('#button-filter').hide();
        $('.box-filter input[type=\'checkbox\']:checked').each(function(element) {
            filter.push(this.value);
        });

        window.location = '<?php echo $action; ?>&filter=' + filter.join(',');
    });
});

Open in new window

ASKER CERTIFIED SOLUTION
M A

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy