Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6560705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:29:42+00:00 2026-05-25T13:29:42+00:00

Project doesn’t need any javascript libraries such as jQuery, Dojo, Prototype so there is

  • 0

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

  1. Is there any ready made STANDALONE script for this purpose?

  2. Is there a pattern , article, post explaining the glitches, points to remember while providing search functionality? something like onkeydown don't do this,

  3. My Idea right now would be have a cached collection of label tags innerHTML then 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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:29:43+00:00Added an answer on May 25, 2026 at 1:29 pm

    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]

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="RealtimeCheckBoxListFiltering.Default" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
      <title></title>
      <script type="text/javascript">
        window.onload = function () {
          var tmr = false;
          var labels = document.getElementById('cblItem').getElementsByTagName('label');
          var func = function () {
            if (tmr)
              clearTimeout(tmr);
            tmr = setTimeout(function () {
              var regx = new RegExp(document.getElementById('inputSearch').value);
              for (var i = 0, size = labels.length; i < size; i++)
                if (document.getElementById('inputSearch').value.length > 0) {
                  if (labels[i].textContent.match(regx)) setItemVisibility(i, true);
                  else setItemVisibility(i, false);
                }
                else
                  setItemVisibility(i, true);
            }, 500);
    
            function setItemVisibility(position, visible)
            {
              if (visible)
              {
                labels[position].style.display = '';
                labels[position].previousSibling.style.display = '';
                if (labels[position].nextSibling != null)
                  labels[position].nextSibling.style.display = '';
              }
              else
              {
                labels[position].style.display = 'none';
                labels[position].previousSibling.style.display = 'none';
                if (labels[position].nextSibling != null)
                  labels[position].nextSibling.style.display = 'none';
    
              }
            }
          }
    
          if (document.attachEvent) document.getElementById('inputSearch').attachEvent('onkeypress', func);  // IE compatibility
          else document.getElementById('inputSearch').addEventListener('keydown', func, false); // other browsers
        };
      </script>
    </head>
    <body>
      <form id="form1" runat="server">
      <table>
        <tr>
          <td>
            <asp:TextBox runat="server" ID="inputSearch" ClientIDMode="Static" />
          </td>
        </tr>
        <tr>
          <td>
            <asp:CheckBoxList runat="server" ID="cblItem" ClientIDMode="Static" RepeatLayout="Flow" />
          </td>
        </tr>
      </table>
      </form>
    </body>
    </html>
    

    [Default.aspx.cs]

    using System;
    using System.Collections.Generic;
    
    namespace RealtimeCheckBoxListFiltering
    {
        public partial class Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                cblItem.DataSource = new List<string>() { "qwe", "asd", "zxc", "qaz", "wsx", "edc", "qsc", "esz" };
                cblItem.DataBind();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Commons JCI project doesn't seem to be maintained since a long time. Are there
My project solution does build without error but doesn't run any more :( I
I've noticed that plenty of opensource project doesn't use BITWISE flags anymore, even if
I want to use a signals/slots library in a project that doesn't use QT.
I have a project with Crystal Reports files that doesn't seem to build correctly
In my Django project I am using Product.objects.all().order_by('order') in a view, but it doesn't
I changed the output path of the test project, because the default path doesn't
For some reason, my visual studio 2008 installation doesn't have the Create Test Project
My project doesn't use the plural convention in table's names. How can I override
Are there general reasons not to deal with Document's and Element's prototype? I like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.