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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:26:32+00:00 2026-05-11T14:26:32+00:00

I want to filter a table with an input box. It works but it

  • 0

I want to filter a table with an input box. It works but it is slow on smartphones which are my target platform – Iphone, Htc Touch HD (800 rows take about 4sec to filter).

Please let me know if you can help speed this up.

function time(){     var now = new Date();     var time = now.getTime();      return time }  function filter (phrase, _id){     var starttime = time();     var words = phrase.value.toLowerCase().split(' ');     var table = document.getElementById(_id);     var ele = null;     var rows = new Array();     for (var r=0 ; r < table.rows.length; r++){         ele = table.rows[r].innerHTML.replace(/<[^>]+>/g,'');         var displayStyle = 'none';         for (var i=0 ; i < words.length; i++) {             if (ele.toLowerCase().indexOf(words[i])!=-1){                 displayStyle = '';             }else {                 displayStyle = 'none';                 break;             }         }         rows[r] = displayStyle;     }     alert((time() - starttime)/1000 +' Sec');     for(var k=0; k < rows.length; k++){         table.rows[k].style.display = rows[k];     } } 
  • 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-11T14:26:32+00:00Added an answer on May 11, 2026 at 2:26 pm

    Sounds like the performance is somewhat reasonable, given the platform, but here are a few ideas:

    1.) Don’t calculate the length of your arrays during each for iteration (see https://developer.mozilla.org/en/A_re-introduction_to_JavaScript#Arrays )

    2.) perform your toLowerCase() on the search string once at the beginning, not during each row checked

    3.) the biggest hog is probably your use of innerHTML and replace(), but it’s going to depend on the browser implementation, see if you can replace it with a more efficient method of getting the text from the cells you need to compare.

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

Sidebar

Related Questions

What I want to do is to filter a table to only show the
I have a UISearchBar which acts as a live filter for a table view.
I want to filter the selectable dates on a datepicker. I basically need to
I'm reading all the files in a single directory and I want to filter
I have a MultipleChoiceField on a form holding car makes. I want to filter
I want to implement an ISAPI filter like feature using HttpModule in IIS7 running
I want to intercept a request in a filter/servlet and add a few parameters
Why would I want to use PHP's filter library? Why wouldn't I? It seems
There are several filter methods for dates (year,month,day). If I want to match a
In MSSQL, when I want to ignore an empty filter parameter, I do the

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.