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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:59:50+00:00 2026-05-26T03:59:50+00:00

This script stops working the moment I add a table inside a table, so

  • 0

This script stops working the moment I add a table inside a table, so how to get it worked?
I don’t need any jQuery solutions, I want pure JavaScript. Here’s my script found on the Internet:

<script>

  function show_hide_column(col_no, do_show) {

    var stl;
    if (do_show) stl = 'block'
    else         stl = 'none';

    var tbl  = document.getElementById('id_of_table');
    var rows = tbl.getElementsByTagName('tr');

    for (var row=1; row<rows.length;row++) {
      var cels = rows[row].getElementsByTagName('td')
      cels[col_no].style.display=stl;
    }
  }

</script>

Here’s my HTML:

<table id='id_of_table' border=1>
  <tr><td colspan="4"><table><tr><td></td></tr></table></td></tr>
  <tr><td>  2</td><td>   two</td><td>   deux</td><td>     zwei</td></tr>
  <tr><td>  3</td><td> three</td><td>  trois</td><td>     drei</td></tr>
  <tr><td>  4</td><td>  four</td><td>quattre</td><td>     vier</td></tr>
  <tr><td>  5</td><td>  five</td><td>   cinq</td><td>f&uuml;nf</td></tr>
  <tr><td>  6</td><td>   six</td><td>    six</td><td>    sechs</td></tr>
</table>

And here’s my Form:

<form>
  Enter column no: <input type='text' name=col_no><br>
  <input type='button' onClick='javascript:show_hide_column(col_no.value,  true);' value='show'>
  <input type='button' onClick='javascript:show_hide_column(col_no.value, false);' value='hide'>
</form>
  • 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-05-26T03:59:51+00:00Added an answer on May 26, 2026 at 3:59 am

    You can leverage the col tag and then the solution is straightforward using only vanilla JavaScript. The col tag has only a few CSS attributes, but visibility is one of them:

    function show_hide_column( col_no, do_show ){
       const table  = document.getElementById( 'id_of_table' )
       const column = table.getElementsByTagName( 'col' )[col_no]
       if ( column ){
          column.style.visibility = do_show?"":"collapse";
       }
    }
    
    const btnHide = document.getElementById( 'btnHide' )
    btnHide.addEventListener( "click", () => show_hide_column( 2, false ))
    
    const btnShow = document.getElementById( 'btnShow' )
    btnShow.addEventListener( "click", () => show_hide_column( 2, true ))
     <table id='id_of_table' border=1>
          <col class="col1"/>
          <col class="col2"/>
          <col class="col3"/>
          <col class="col4"/>
          <tr><td colspan="4"><table><tr><td></td></tr></table></td></tr>
          <tr><td>  2</td><td>   two</td><td>   deux</td><td>     zwei</td></tr>
          <tr><td>  3</td><td> three</td><td>  trois</td><td>     drei</td></tr>
          <tr><td>  4</td><td>  four</td><td>quattre</td><td>     vier</td></tr>
          <tr><td>  5</td><td>  five</td><td>   cinq</td><td>fÜnf</td></tr>
          <tr><td>  6</td><td>   six</td><td>    six</td><td>    sechs</td></tr>
        </table>
        <button id="btnHide">hide French</button>
        <button id="btnShow">show French</button>

    References:

    • col
    • visibility on quirksmode
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have: $(#option1).live(click, function(){ $(.active).removeClass('active'); $(this).addClass('active'); $(#main).load(option1.php, function(){ }); }); and the script inside
For this script, it checks to see if the file is a microsoft words
I have this script: select name,create_date,modify_date from sys.procedures order by modify_date desc I can
I'm using this script to display all the images in a folder, but I
Well basically I have this script that takes a long time to execute and
I have this script which basically toggles a bgColor class on and off so
I got this script called rapidshare link checker v2 php by Bigfish At the
Can someone explain why this script throws an exception? $byteArray = @(1,2,3) write-Output (
I want to execute this script (view source) that uses Google Translate AJAX API
I've got this script on my website : $(document).ready(function() { function filterPath(string) { return

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.