Can you check what's on in Galway on another date without touching the mouse?
You're checking a Galway events page. It shows three events for Saturday. You pick Sunday using the keyboard. What should change on the page, and where should your next key press go?
You already know how a web page puts text next to a control. Before writing the filter, list what your visitor needs: a clear label, keyboard access and a count for the chosen date. Here the label's for attribute matches the list's ID. The first date is selected by default, with three events shown below.
When you confirm a new choice, thirteen December, the browser fires a change event. A JavaScript function reads the stored date value, finds five in the sample lookup and writes five events below the filter. This function is called an event handler. Updating the result text leaves focus on the filter.
You choose thirteen December using the keyboard. You can see thirteen Dec in the list, but the option also stores a date in year, month, day order. Which value does the handler get from the list? Pick one answer.
Start with three sample counts keyed by date. Once the HTML is in place, find the filter and the result paragraph. Listen for a change on the filter. Inside the handler, read its current value and use it to look up the count. Replace just the paragraph's text.
Start on twelve December, with three events showing. Tab to the date filter and choose thirteen December. The handler reads the new value and looks up five. Now choose fourteen December. This time the lookup gives zero. You can make both changes without tabbing back because only the result text changes.
Now try a different set of sample counts. Twelve December has four events, thirteen December has eight, and fourteen December has two. Starting on the twelfth, you choose the thirteenth and then the fourteenth. What should you see after each change? Pick the sequence.
On the left, the button changes colour and the count stays at three. That version only changes the style and never looks up the new date. On the right, you choose thirteen December and see the count change to five. The handler reads the date and leaves focus on the filter.
In SQLite, create an events table with an integer primary key and text fields for the date and title. Insert the sample events. Run the count query once for each filter date, passing that date as the parameter. Copy the retrieved counts, three, five and zero, into your JavaScript lookup.