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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:54:59+00:00 2026-06-01T02:54:59+00:00

Issue In the below code , say if i want to change the color

  • 0

Issue
In the below code , say if i want to change the color of the cell 1 ,2 and 4 , then they change the color at different intervals. (say first 1 changes then 2 changes then 4 changes)

I want all of them (1,2 and 4) to change the color at the same time.
That will look like all (1,2 and 4) are red , then all the 3 are blue again.

Here temp_array will have the cells that i have to change the color (say temp_array will have 1,2 and 4.

 function startChangingColor()
       {
            var temp;
            for(var i=0;i<temp_array.length;i++)
            {
                temp = temp_array[i];
                intervalid[i] = setInterval( createCB(temp) ,300);
            }
        }
        function createCB( val )
        {
           return function()
           {
              changeColor( val );
           };
        }

        var flag = true; 
        function changeColor (element)
        {
            if(flag==true)
            {
                 document.getElementById(CELL+element).className='redled';
                 flag=false;
            }
            else if (flag==false)
            {
                 document.getElementById(CELL+element).className='grayled';
                flag = true;
            }
        }
  • 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-01T02:55:01+00:00Added an answer on June 1, 2026 at 2:55 am

    Don’t know if I’m reading this correctly but try this:

    var
      cells = document.getElementsByTagName('td'),
      tempArray = [[0, 1, 3], [1, 2, 0]];
    
    var createColorChanger = function (classNames, elements, elementSelection) {
      var currentIndex = 0;
    
      return function () {
        var className = classNames.shift(), i = 0, lim = elements.length;
        classNames.push(className);
    
        for (; i < lim; i += 1) {
          elements[i].className = elementSelection[currentIndex].indexOf(i) > -1 ? className : '';
        }
    
        currentIndex += 1;
        if (currentIndex >= elementSelection.length) {
          currentIndex = 0;
        }
      }
    };
    
    setInterval(createColorChanger(['grayled', 'redled'], cells, tempArray), 1000);
    

    demo: http://jsfiddle.net/NZPTE/3/

    ​

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

Sidebar

Related Questions

I met an interesting issue about C#. I have code like below. List<Func<int>> actions
I have an issue with this jquery code below. Please give me advice or
I have the following SQL design issue. The code below might look a little
There's code below, but this is also a conceptual issue. The question: Are the
The code below works in FF, Safari, Chrome. But IE is giving me issues.
Hello everyone I'm currently having 2 issues with the code below: Upon return of
I'm trying to learn C++ currently, but I'm having issues with the code below.
UPDATE: As it turns out, the below is caused by a caching issue on
This issue came up when I got different records counts for what I thought
I want to convert a time string say '12:05 PM' into a datetime using

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.