mercredi 24 juin 2020

JQuery multiple checkbox selection "or" instead of "and"

In my shopify liquid code, in a for loop, I create multiple <ul> elements with multiple checkboxes inside each <ul> for selected tags. If a 1st checkbox is clicked, the tag is added to the url: .../tag1. If I select a 2nd checkbox, the 2nd tag is added to the url, the url then looks like .../tag1+tag2. I need the condition to be "or" when the checkboxes are located inside the same <ul> and "+", so "and", only for different <ul>. Example, one <ul> is for "artist", another for "price". If two artist checkboxes are ticked and one for price, I want to show the selected price tag for artist1 and selected price tag for artist2. So: If (artist-tag1 or artist-tag2) and price-tag1. At the moment all checkboxes are with "+" condition. Any ideas how to do that would be heavily appreciated! My liquid code and JQuery:



$('.filter_checkbox').off().change( function(){
var newURL = $(this).nextAll('a').attr('href');
window.location.href = newURL;
});



Aucun commentaire:

Enregistrer un commentaire