J’utilise un calendrier complet dans jQuery pour sélectionner et rechercher des événements que je veux. Chaque fois qu’ils cliquent sur le bouton, un modal apparaît. Ainsi, lorsqu’ils sélectionnent un événement ou une ville désignée, un résultat apparaît. Ceci est le HTML, ce sont les conditions:
Les 2 conditions fonctionnent, mais la troisième ne le fera pas
Events
Select an Event 1 2 3 4 5 6 7 All Search a City City1 City2 City3 City4 City5
Fichier JSON
{ "title": "Tasting Festival", "start": "start date", "tags": "1", "imageurl": "", "products": [ { "name": "City 1", "url": "", "time": "", "location": "" }, { "name": "", "url": ", "time": "", "location": "" } ] } $("#searchnow").click(function () { var selectedCity = $("#searchcity").val(); var selectedEvent = $("#search").val(); $.getJSON('events.json', function (data) { render(selectedCity, selectedEvents, data); }); }); function render(selectedCity, selectedEvent, data) { $(".order-details-table").empty(); $(data).each(function (i, v) { if(v.products) $(v.products).each(function(index,p){ if (selectedCity == 'all' || p.name == selectedCity) { $(".order-details-table").append('' + p.name + ' ' + v.title + '
' + p.time + ' ' + p.location + ' Register! '); } if (selectedEvent == v.tags && selectedCity == p.name ){ $(".order-details-table").append('' + p.name + ' ' + v.title + '
' + p.time + ' ' + p.location + ' Register! '); } if (selectedEvent == 'all' || v.tags == selectedEvent) { $(".order-details-table").append('' + p.name + ' ' + v.title + '
' + p.time + ' ' + p.location + ' Register! '); } }); }); }