Project doesn’t need any javascript libraries such as jQuery, Dojo, Prototype so there is no easy way i suppose. I would like to have in-depth answers for the question explaining how would one do this. As most of you might know asp.net checkboxlist emits a markup like below in Flow repeatLayout.
<span>
<checkbox><label></br>
<checkbox><label></br>
<checkbox><label></br>
</span>
i haven’t put the ending/closing tags for simplicity. We have a textbox for searching through this list of checkbox.Now comes the question,
How would i Filter the checkboxlist when user types the search term in the textbox and hide the unmatched checkbox+label.
some more questions i would like getting answers for that are related to above
-
Is there any ready made STANDALONE script for this purpose?
-
Is there a pattern , article, post explaining the glitches, points to remember while providing search functionality? something like
onkeydown don't do this, -
My Idea right now would be have a cached collection of label tags
innerHTMLthen loop through each tag and check for search term, when found hide all others but show only matching.[My Concern is what will happen when list is too long, on every keypress looping is not the best idea i suppose]
Your suggestions, answers, solution, scripts are welcome
This solution is based on Ktash’s answer. I made it cause I want to learn more about javascript, DOM navigating and RegExp.
I changed “keypress” event with “keydown” since the previous doesn’t trigger on backspace/delete so deleting all the characters with backspace/delete still left the list filtered.
[Default.aspx]
[Default.aspx.cs]