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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:45:13+00:00 2026-05-11T09:45:13+00:00

I have the below HTML code, also I will have a textbox for entering

  • 0

I have the below HTML code, also I will have a textbox for entering the keyword, What I want is while the user writing in this textbox the javascript search in this HTML code using the FirstName and LastName, and while comparing items, if an item didn’t match I want to display: none its container div. How can I do that using JS and work on firefox and IE

<div id='contact_4'>     <input class='contactChk' id='chk_4' type='checkbox' />     <img alt='' src='img/4.jpg' width='25px' height='25px' />     <span id='contactName_4' class='contactItem'>         FirstName LastName     </span>     <br /> </div> <div id='contact_5'>     <input class='contactChk' id='chk_5' type='checkbox' />     <img alt='' src='img/5.jpg' width='25px' height='25px' />     <span id='contactName_5' class='contactItem'>         ACharName AnyLast     </span>     <br /> </div> <div id='contact_6'>     <input class='contactChk' id='chk_6' type='checkbox' />     <img alt='' src='img/6.jpg' width='25px' height='25px' />     <span id='contactName_6' class='contactItem'>         BCharName AnyLast     </span>     <br /> </div> <div id='contact_7'>     <input class='contactChk' id='chk_7' type='checkbox' />     <img alt='' src='img/7.jpg' width='25px' height='25px' />     <span id='contactName_7' class='contactItem'>         CCharName AnyLast     </span>     <br /> </div> 
  • 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. 2026-05-11T09:45:13+00:00Added an answer on May 11, 2026 at 9:45 am

    This looks very inefficient if you have a larger set of contacts to be displayed. The easiest way would be to use jQuery and bind a function to keyup event of your text field: (assuming the above code is contained inside something like <div id='contactlist'>)

     var searchstring = '';  function filterContact() {   var jthis = $(this); // should give a tiny performance gain   if ($('span.contactItem', this).text().toLowerCase().indexOf(searchstring) >= 0) {     jthis.addClass('matching');     jthis.removeClass('nonmatching');   } else {     jthis.addClass('nonmatching');     jthis.removeClass('matching');   } }  function filterContacts() {   var elem = $('input#yourtextfield')[0];   searchstring = elem.value.toLowerCase(); // because we like to match all cases   searchstring = searchstring.replace(/^\s+/,'').replace(/\s+$/,''); // trim    $('#contactlist div').each(filterContact); }  function initFiltering() {   $('input#yourtextfield').live('keyup',filterContacts); }  $(document).ready(initFiltering); 

    Also add .matching and .nonmatching classes to your CSS. (display: block and none)

    As said, this is quite inefficient, not only by memory (and bandwidth) needed but also by CPU time on filtering (plus rendering time). It could be faster if you process that data inside some array or if you have very large datasets you should fetch the filtered data paginated from server on demand (can also be done by jQuery’s AJAX functions). You could also filter delayed in case the user is still typing (filter only if he stopped typing for ~500ms).

    toLowerCase() could have some difficulties with non-ASCII input; so if you need it you should test it on your target languages.

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

Sidebar

Ask A Question

Stats

  • Questions 116k
  • Answers 116k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I have gotten it to work as follows: Use XML… May 11, 2026 at 10:30 pm
  • Editorial Team
    Editorial Team added an answer I think there are two problems in the methods. Let's… May 11, 2026 at 10:30 pm
  • Editorial Team
    Editorial Team added an answer You should run "devenv.exe /installvstemplates" to update VS template cache. May 11, 2026 at 10:30 pm

Related Questions

I'm just beinning basic data driven ASP.NET webforms design. I have the first part
The following code is visual basic, .NET, ASP... all of the above? Can anybody
I'm trying to send an email message using the .NET MailMessage class which can
Is it possible to set the cursor to 'wait' on the entire html page

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.