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

  • Home
  • SEARCH
  • 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 9240409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:11:06+00:00 2026-06-18T08:11:06+00:00

I need guidance editing a file. I have posted the Javascript below. This is

  • 0

I need guidance editing a file. I have posted the Javascript below. This is a link to my working example http://www.closetos.com/top-shelf-awards_copy_copy.

The problem occurred when I added an additional row to the table. Now, when you select the text link in a cell in the second row, it stays selected and active, when clicking on something in the top row.

function $(id)
{
return document.getElementById(id);
}

function Coalesce(Value, Default)
{
if(Value == null)
return Default;

return Value;
}

function Switcher(numberOfSections, sectionContainerID, activeClass, inactiveClass)
{
this.NumberOfSections   = Coalesce(numberOfSections, 1) - 1;
this.SectionContainerID = Coalesce(sectionContainerID, "sectionContainer");
this.ActiveClass        = Coalesce(activeClass, "active");
this.InactiveClass      = Coalesce(inactiveClass, "");
}

Switcher.prototype.Switch = function(TheLink, SectionID)
{
// Make sure all sections are hidden
var SectionContainer = $(this.SectionContainerID);
for(var ct = 0; ct < SectionContainer.childNodes.length; ct++)
{
var node = SectionContainer.childNodes[ct];
if(node.nodeType != 1)
    continue;

node.style.display = "none";
}

var First = true;
// Reset button styles
for(var ct = 0; ct < TheLink.parentNode.childNodes.length; ct++)
{
if(TheLink.parentNode.childNodes[ct].nodeType != 1)
    continue;
else node = TheLink.parentNode.childNodes[ct];

node.className = this.InactiveClass;

if(First)
{
    node.className += " firstCell";
    First = false;
}
}

// Show the selected section
$(SectionID).style.display  = "block";

TheLink.className = this.ActiveClass;
if(TheLink == node)
TheLink.className += " lastCell";
}
  • 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-18T08:11:07+00:00Added an answer on June 18, 2026 at 8:11 am

    You problem is in this section of code. this looks only at the row that the clicked cell is in. TheLink.parentNode is a reference to the row that the cell is in.

    for(var ct = 0; ct < TheLink.parentNode.childNodes.length; ct++) <--- parenNode == row
    {
        if(TheLink.parentNode.childNodes[ct].nodeType != 1)
        {
             continue;
        }
        else 
        {
            node = TheLink.parentNode.childNodes[ct];
        }
    
        node.className = this.InactiveClass;
    
        if(First)
        {
            node.className += " firstCell";
            First = false;
        }
    }
    

    In order to make this work with multiple rows you need to modify it to look at other rows in the table:

    for(var ct = 0; ct < TheLink.parentNode.parentNode.childNodes.length; ct++) 
        {   
            
            for( innerL = 0; innerL < TheLink.parentNode.parentNode.childNodes[ct].childNodes.length; innerL++)
            { 
                if(TheLink.parentNode.parentNode.childNodes[ct].childNodes[innerL].nodeType != 1)
                {
                     continue;
                }
                else 
                {
                    node = TheLink.parentNode.parentNode.childNodes[ct].childNodes[innerL];
                }
        
                node.className = this.InactiveClass;
        
                if(First)
                {
                    node.className += " firstCell";
                    First = false;
                }
            }
        }
    

    in the block above you are looking at the parentNode’s (the tr) parentNode (tbody) and then iterating through its grandchildren. This allows you to capture all the cells in the table, not just the row.

    Here is an example of it working. When you follow the link you need to hit the green ‘run’ button on the bottom left of the page to get the script to load.

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

Sidebar

Related Questions

I am new in this field and i desperately need some guidance from u
I am in need of some guidance for the following design. I have a
This question is more about guidance than actually solving my problem: I need to
I really need some guidance here as this issue is pretty confusing and extremely
I have a problem that I need guidance with. I have an array that
I am working on a picture editing tool in which I need to merge
I need some guidance for following : I have an ActionSheet. When it appears
I would like to start working with Zend Framework 2 and need some guidance
Need some guidance figuring out what went wrong. I've been using mysql, phpmyadmin for
I need some guidance around which approach to use to load binary files from

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.