Hi guys, I was wondering if anyone knew a way of hiding duplicate (in terms of a name field) items displayed in a collection list. At the moment I have created a form which allows users to submit locations, but now multiple duplicates of the locations can be submitted.
You can use this snippet if the duplicates are based on text. Replace “.filter-component” with your own class that you wish to loop through.
document.addEventListener("DOMContentLoaded", function dumpDups() {
const rr = new Set();
for (const div of document.querySelectorAll(".filter-component")) {
if (rr.has(div.textContent.trim())) {
div.parentNode.removeChild(div);
}
rr.add(div.textContent.trim());
}
dumpDups();
});
Hey @RhinoReign. Thanks so much for this script. It works really well on text elements. Is there any way it can be altered to find duplicates in a list of checkboxes?
Did you find the solution when you want to hide checkboxes that are duplicates? The current problem I’m having now is that the duplicates are gone but only the text and not the checkboxfields.