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 7653541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:03:29+00:00 2026-05-31T12:03:29+00:00

I have a list of items stored in a database. I am using a

  • 0

I have a list of items stored in a database.

I am using a foreach to list the items returned with a checkbox next to each item like so:

            var db = Database.Open("database");
            var sql = "SELECT * from table";
            var result = db.Query(sql);

…

@{foreach (var user in result) {
            <tr><td>@table.attribute</td> <td>@table.secondAttribute @table.thirdAttribute</td>
                <td><input type="checkbox" name="attribute" value="attribute" /></td></tr>

The functionality I would like to have is a textbox which, upon the user typing a letter, would limit the number of items listed by my foreach based on what character the user enters. So I’ve tried to use the JQuery autoComplete module, but I’m not entirely sure how to use it in this case, or even if it is possible.

So I added in :

 $(function(){
            $('#name').autocomplete({source:'getUsers'});
        });

…
Enter their name:

And then in getUsers :

@{
    var db = Database.Open("database");
    var term = Request.QueryString["term"] + "%";
    var sql = "SELECT * from table where attribute LIKE @0 OR secondAttribute LIKE @0 OR thirdAttribute LIKE @0";
   var result = db.Query(sql, term);
    var data = result.Select(p => new{label = p.attribute + " " + p.secondAttribute});
    Json.Write(data, Response.Output);
}

This, of course, just retrieves the data for the textbox and doesn’t delimit the returned checkboxes at all. Is there a way I can do this ?

  • 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-31T12:03:30+00:00Added an answer on May 31, 2026 at 12:03 pm

    If client-side only search is acceptable as per your comment, here’s a really simple way to do it:

    $(document).ready(function() {
       var $rows = $("tr");
    
       $("#yoursearchinput").keyup(function() {
           var val = $.trim(this.value);
           if (val === "")
               $rows.show();
           else {
               $rows.hide();
               $rows.has("td:contains(" + val + ")").show();
           }
       });
    });
    

    Demo: http://jsfiddle.net/k5hkR/

    Note that the above will do a case sensitive search. Here is a slightly more complicated version that does a case insensitive search:

    $(function() {
        var $cells = $("td");
    
        $("#search").keyup(function() {
            var val = $.trim(this.value).toUpperCase();
            if (val === "")
                $cells.parent().show();
            else {
                $cells.parent().hide();
                $cells.filter(function() {
                    return -1 != $(this).text().toUpperCase().indexOf(val);
                }).parent().show();
            }
        });
    });​
    

    Demo: http://jsfiddle.net/k5hkR/1/

    The second solution is just something I whipped up to give you the general idea – obviously it can be tidied up and made more efficient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of records inserting into a SQL Server database using a
I have a php page where I add and delete items from database using
I'm using the new ASP.Net ListView control to list database items that will be
I have list of items in my dropdown. Now I wish to select item
I have a List<NameClass> that stores a collection of NameClass items with a property
I have a record store which holds a list of shopping items i am
I have a list which is dynamically built, but there are empty list items
Can someone suggest what I am doing wrong? Basically I have a List Items,
I have List with n items. I wish transform my list to new list,
I have a list of items that I am displaying in a floated list,

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.