Howdy Community,
I understand there is a previous post for the same issue (
https://community.hubspot.com/t5/CMS-Development/Filtering-HubDB-elements-with-HTML-Checkboxes/m-p/297319 ) but I don’t believe a solution has been found.
I have tried many options, but figured some help would get me going. My thoughts have been 2:
1) try to set the filters each time I make a query to HubDB (similarly to the famous Real Estate tutorial, and set in the aforementioned post) or
2) make only one giant query to retrieve the data from HubDb and then filter them (similarly to React).
The first method is easier said than done, I have though about entering a “submit button” to submit all the checked boxes at once, but the line
\`{% set typequery = typequery ~ "&type="~request.query\_dict.type\|urlencode %}\`
would give me a URL like this:
\`?type=1&type=4&topic=1&topic=2\`,
which does not work. Looking around I have found that a correct URL should be
\`?type=1+4&topic=1+2\`
but I am not sure how to get to that uRL encoding.
The second method has its own challenges. My line of thought was this:
first, in the JS panel create an empty array;
second, `document.querySelectorAll(`input[name=“${name}”]:checked`)` and push them into the array;
third, display each element of the array, from the HTML/hubl panel.
Unfortunately, I have not figured out yet how to fire a function and use a variable from the JS panel to the HTML/hubl panel.
Any help or suggestion is greatly appreciated!