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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:02:30+00:00 2026-06-12T18:02:30+00:00

I have a code which creates html reports. It uses html tables to display

  • 0

I have a code which creates html reports.

It uses html tables to display the results, the tables are sortable, and they are zebra striped automatically, so there is already Javascript and its all embedded inline, so that the file can be simply shared with its users.

I don’t have a great grasp of Javascript, and doing that already was hard enough. However, a problem now is that sometimes some of the cells have A LOT of data in them. It is by design however, and I am hoping to find an elegant solution to this.

What I would like is a Javascript function or suite of functions where I can press on any cell in my table and have it toggle visibility.

In other words – there is a table with many cells rows and columns. When the user presses one cell, its contents are invisible, so the rest of the table will re-size itself. Thus – a cell with many lines of content which re-sizes the rows height, will collapse in size.

In this method, many rows of data which have a cell which heightens it can be compared much easier since the large cell is invisible.

I have found solutions which implement buttons outside the table to hide entire rows or columns. Buttons with input fields you can define an ID and have it hide that ID. I do not think it smart to have a different unique ID to each cell, I want something simpler.

A global function that catches any onclick event on a cell which well make that cells contents toggle visibility.

I know I have repeated my desire multiple times, but hopefully this has made my desire more clear.

Edit:

This is the final code I went for in the end. Seems to work nicely:

function tableclick(e) 
{
    e = e || window.event;
    var target = e.target || e.srcElement;
    while(target != this && (!target.tagName || target.tagName != "TD")) target = target.parentNode;
    if( target != this) 
    {
        toggleVis(target)
    }
}

function toggleVis(obj) 
{
    if ( obj.style.fontSize != "0px" ) 
    {
        obj.style.fontSize = "0px"
    }
    else 
    {
       obj.style.fontSize = "16px"
    }
}

and then simply add onclick=tableclick(event) to your table.

  • 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-12T18:02:32+00:00Added an answer on June 12, 2026 at 6:02 pm

    Attach an onclick event to the table, and look at the event’s target.

    table.onclick = function(e) {
        e = e || window.event;
        var target = e.target || e.srcElement;
        while(target != this && (!target.tagName || target.tagName != "TD")) target = target.parentNode;
        if( target != this) {
            // "target" is the cell that was clicked. Do something with it.
        }
    }
    

    Side-note: You don’t need JavaScript to zebra-stripe the rows. Just use CSS:

    tr {background-color:white}
    tr:nth-child(even) {background-color:black;}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which creates a new table. var html = '<table>';
I have the following code which creates a simple window with two buttons which
I have the following code which creates an ImageButton and plays a sound when
I have created some python code which creates an object in a loop, and
I have this code, which creates an image, and then adds some effects to
I have a working JavaScript code below which dynamically creates JSON object using JSON.parse
I have written a multi threaded java code, which when runs creates 8 threads
I have the following code which takes an input from an xml and creates
I have a jQuery code which runs on dom ready. It also creates elements
Suppose I have the following code which creates two radio buttons: <li id=foli517 class=

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.