Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Aug 2012
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I hide a few fields in a specific row

    Hi

    I have created a table that dynamically adds 24 rows and adds html to each column (5 columns)

    What I need to do is if the row contains "TOTAL 1" or "TOTAL 2"
    I want to hide column 2, column 3 and 4.
    How do I do this?
    Attached Files Attached Files

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,226
    Thanks
    23
    Thanked 606 Times in 605 Posts
    I just added this to a different thread. No need to re-do it. you should be able to see how to use rows and cells in JS to do what you want to do.

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title>Title of the document</title>
    <style type="text/css">
    #my_table td{
    	text-align:center;
    }
    #my_table th{
    	text-align:center;
    	background-color: gray;
    }
    </style>
    </head>
    
    <body>
    <table border="1" width="104%" cellspacing="0" cellpadding="3" id="my_table">
    <tr>
    <th class="myaccount">Check</th>
    <th class="myaccount">ID</th>
    <th class="myaccount">Surname</th>
    <th class="myaccount">Firstname</th>
    <th class="myaccount">Lastname</th>
    <th class="myaccount">Class</th>
    <th class="myaccount">Level</th>
    <th class="myaccount">Student ALT ID</th>
    </tr>
    
    <tr class="row">
    <td><input name="studentID[]" type="checkbox" id="studentID[]" onchange="get_info(1);"></td>
    <td>81</td>
    <td>Adeola</td>
    <td>Ndubuisi</td>
    <td>Rachael</td>
    <td>Hibscuis</td>
    <td>JSS-1</td>
    <td>1234</td>
    </tr>
    
    <tr class="row">
    <td><input name="studentID[]" type="checkbox" id="studentID[]" onchange="get_info(2);"></td>
    <td>52</td>
    <td>Oladejo</td>
    <td>Abiola</td>
    <td>Mutiu</td>
    <td>Hibscuis</td>
    <td>JSS-1</td>
    <td>9500</td>
    </tr>
    </table>
    
    <script type="text/javascript">
    function get_info(row){
    	var baset = document.getElementById("my_table").rows[row];
    	for (y=1; y <= baset.cells.length; y++){
    		var x = baset.cells[y].innerHTML;
    		alert (x);
    	}
    }
    </script>
    </body>
    </html>
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •