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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:34:09+00:00 2026-06-01T13:34:09+00:00

I wrote the function using js+jQuery. Here is a link to a jsFiddle which

  • 0

I wrote the function using js+jQuery.

Here is a link to a jsFiddle which shows my problem: http://jsfiddle.net/anarnold/LpBaW/

The goal of this function is to scan a table and check for rows that have certain field (td) values matching. Rows then get assigned a class denoting whether or not they are unique, and the number of matching rows are printed into the final field (td) of each row.

It basically uses a nested loop of this structure:

For each row…
scan the whole table for matches..

The way I identify rows is to concatenate the field (td) texts from each row into a rowid attribute on the final field (td) for each row.

The current funciton works fine, but it gets very slow with large tables ~2000 rows.

There must be a more efficient and elegant way to accomplish this. Any help would be greatly appreciated!

  • 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-06-01T13:34:10+00:00Added an answer on June 1, 2026 at 1:34 pm

    Here is an example of using an associative array to store the results and then iterate on that:

    http://jsfiddle.net/AdDMk/

    var rowIdCnt = {};
    
    function unqOrMsgTest() {
        // Store counts here
        var rowIdCnt = {};
    
        // loop through check tds
        $("#binning tr td[col=check]").each(function() {
    
            // grab row identifer to check against other rows        
            var rowId = $(this).attr("rowid");
    
            if (rowId in rowIdCnt) {
                rowIdCnt[rowId] ++;
            } else {
                rowIdCnt[rowId] = 1;
            }
    
        });
    
        // Now iterate over each count and update the table appropriately:
        $.each(rowIdCnt, function(rowId, cnt) {
            //this bit of logic picks a class to assign rows        
            var resultClass = "notUnique";
            if (cnt < 2) {
                resultClass = "unique";
            }
    
            //apply the row class and print the redundancy number into td
            $('#binning tr td[rowid='+rowId+']').text(cnt).parent().addClass(resultClass);
    
        });
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a function to match fingerprint templates using VC++.NET. Now I want to
I wrote a simple example, which estimates average time of calling virtual function, using
I am requesting with AJAX (using jQuery) a tag which contains a Javascript function
I have strange problem with the delay function here using the HTML function with
I need to write, in JavaScript (I am using jQuery), a function that is
This next challenge of mine involves jqtransform which can be found here http://www.dfc-e.com/metiers/multimedia/opensource/jqtransform/ I
I wrote a custom validator using MVC DataAnnotations and the jQuery unobtrusive javascript library.
I'm using jQuery UI's draggable and droppable libraries in a simple ASP.NET proof of
I have a slideshow component that I wrote in javascript using jQuery. The slideshow
Using jQuery v1.6.4, I'm trying dynamically format some objects. Here is my code: <html>

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.