Welcome visitor
* Login
* Register
It is currently January 21st, 2019, 11:39 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » JavaScript



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  Hide Rows
PostPosted: September 3rd, 2009, 9:15 pm 

Posts: 27
I have this table and those buttons. I want to hide the rows that are checked whith the hide button and show them again with the other button. I have problems hidding the rows, i can hide a checkbox at a time but not the entire row, neither all checked boxes through a loop. please help.
<table>
  <tr>
    <td><input type="checkbox" id="box1" />
    </td><td>a mmmmmmmmmmmmmm</td>
  </tr>
    <tr>
    <td><input type="checkbox" id="box2" /></td>
    <td>b mmmmmmmmmmmmmm</td>
  </tr>
    <tr>
    <td><input type="checkbox" id="box3" /></td>
    <td>c mmmmmmmmmmmmmm</td>
  </tr>
    <tr>
    <td><input type="checkbox" id="box4" /></td>
    <td>d mmmmmmmmmmmmmm</td>
  </tr>
    <tr>
    <td><input type="checkbox" id="box5" /></td>
    <td>e mmmmmmmmmmmmmm</td>
  </tr>
</table>
<input type="button" value="hide" onclick="hd();" />
<input type="button" value="show all" onclick="sh();" />
function hd(){
box=document.getElementById('box1');
if (box.checked==true){box.style.display='none';}}
function sh(){
box=document.getElementById('box1');
box.style.display='inline';}


Top
 Profile  
 
  Re: Hide Rows
PostPosted: September 4th, 2009, 7:49 pm 
User avatar

Posts: 79
something like this?
<script type="text/javascript">
function hd(){
  tch=document.getElementById('table').getElementsByTagName('input');
  rth=document.getElementById('table').getElementsByTagName('tr');
  for (i=0; i<tch.length; i++){
    if (tch[i].checked==true){
      rth[i].style.display='none';
    }
  }
}
function sh(){
  tch=document.getElementById('table').getElementsByTagName('input');
  rth=document.getElementById('table').getElementsByTagName('tr');
  for (i=0; i<rth.length; i++){
    tch[i].checked=false;
    rth[i].style.display='inline';
  }
}
</script>
<table id="table" >
  <tr>
    <td><input type="checkbox" /></td>
    <td>a mmmmmmmmmmmmmm</td>
  </tr>
    <tr>
    <td><input type="checkbox" /></td>
    <td>b mmmmmmmmmmmmmm</td>
  </tr>
    <tr>
    <td><input type="checkbox" /></td>
    <td>c mmmmmmmmmmmmmm</td>
  </tr>
    <tr>
    <td><input type="checkbox" /></td>
    <td>d mmmmmmmmmmmmmm</td>
  </tr>
    <tr>
    <td><input type="checkbox" /></td>
    <td>e mmmmmmmmmmmmmm</td>
  </tr>
</table>
<input type="button" value="hide" onclick="hd();" />
<input type="button" value="show all" onclick="sh();" />


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » JavaScript


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron