Show/hide column
- Nina07
- Born


- Joined: Jun 16, 2010
- Posts: 2
- Status: Offline
Hi,
this is an example of the website i'm working on:
I can show and hide textblocks by clicking on the title. I want to do more or less the same with a column in the 'composition' part of the site. I want to be able to click on an image under the table to show and hide the column 'drawing' (= the second column.) But I can't get this to work. The only solution I have so for is to use two images (one to show the column and one to hide it again). Is there a way to use just one image to get the same result? (currently the image on the right is to show the column en the left image is to hide the column)
Thanks,
Nina
this is an example of the website i'm working on:
Code: [ Select ]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html lang="NL">
<head><title>
Tooling
</title>
<script type="text/javascript" src="/scripts/swfobject.js"></script>
<script type="text/javascript" src="/scripts/showpic.js"></script>
<script type="text/javascript">function toggle(id) {
var e = document.getElementById(id);
if (e.style.display == '')
e.style.display = 'none';
else
e.style.display = '';
}
</script>
<script language="JavaScript" type="text/javascript">
<!--
function AddRemoveCol(id, ar){
var rows=document.getElementById(id).getElementsByTagName('TR');
var zxc0,zxc2,zxccols;
for (zxc0=0;zxc0<rows.length;zxc0++){
cols=rows[zxc0].getElementsByTagName('TD');
colsnu=cols.length-1
for (zxc1=0;zxc1<=colsnu;zxc1++){
if (!cols[zxc1].set){ cols[zxc1].set='X'; }
if(cols[zxc1].style.display=='none'&&ar){
cols[zxc1].style.display='';
cols[zxc1].set='show';
break;
}
if(cols[colsnu-zxc1].style.display==''&&!ar&&cols[colsnu-zxc1].set=='show'){
cols[colsnu-zxc1].style.display='none';
cols[colsnu-zxc1].set='hide';
break;
}
}
}
}
//-->
</script>
</head>
<body>
<div class="inhalt"><a href="#self" onclick="toggle('box')" class="style3"><span class="subtitle">Availability</span></a>
<div id="box"style="display:none"><p class="style2"><strong>This article is available</strong></p>
<table style="width: 100%">
<tr>
<td style="width: 386px"><em>Packaging</em></td>
<td><em>Price</em></td>
</tr>
<tr>
<td style="width: 386px">20 pieces</td>
<td>€1.73</td>
</tr>
</table><br/>
</div>
</div>
<div class="inhalt"><a href="#self" onclick="toggle('box1')" class="style3"><span class="subtitle">Stock</span></a><div id="box1"style="display:none">
<p ><span class="bold">The following colours are in stock</span></p>
<table style="width: 100%">
<tr>
<td style="width: 386px"><em>Color</em></td>
<td><em>Location</em></td>
</tr>
<tr>
<td style="width: 386px">00</td>
<td> </td>
</tr>
</table>
<br/>
</div>
</div>
<div class="inhalt">
<a href="#self" onclick="toggle('box3')" class="style3"><span class="subtitle">Composition</span></a>
<div id="box3" style="display:none"><p ><span class="bold">Articles (Inclusive)</span></p>
<table id='id_of_table'style="width: 613px">
<tr>
<td style="width: 12px; height: 17px;"><em>N°</em></td>
<td style="display:none; height: 17px;" style="width: 102px"><em>Drawing</em></td>
<td style="width: 63px; height: 17px;"><em>Article</em></td>
<td style="width: 65px; height: 17px;"><em>Quantity</em></td>
<td style="width: 202px; height: 17px;"><em>Description</em></td>
<td style="width: 298px; height: 17px;"><em>Material</em></td>
<td style="width: 217px; height: 17px;"><em>Tolerance</em></td>
</tr>
<tr>
<td style="width: 12px; height: 15px;" valign="top"></td>
<td style="display:none; height: 15px;" style="width: 102px; height: 15px;" valign="top">
<img height="90" src="images/06577053_182429.png" width="47" /></td>
<td style="width: 63px; height: 15px;" class="copyblue" valign="top">
</td>
<td style="width: 65px; height: 15px;" valign="top"></td>
<td style="width: 202px; height: 15px;" valign="top"></td>
<td style="width: 298px; height: 15px" valign="top"></td>
<td style="width: 217px; height: 15px" valign="top"></td>
</tr>
</table>
<a href="#self" onClick= "AddRemoveCol('id_of_table', true);" ><img height="26" src="images/showhideafbeelding.jpg" style="float: right" width="26" /></a>
<a href="#self" onClick= "AddRemoveCol('id_of_table',false);" ><img height="26" src="images/showhideafbeelding.jpg" style="float: right" width="26" /></a><br/>
</div></div>
</body>
<html lang="NL">
<head><title>
Tooling
</title>
<script type="text/javascript" src="/scripts/swfobject.js"></script>
<script type="text/javascript" src="/scripts/showpic.js"></script>
<script type="text/javascript">function toggle(id) {
var e = document.getElementById(id);
if (e.style.display == '')
e.style.display = 'none';
else
e.style.display = '';
}
</script>
<script language="JavaScript" type="text/javascript">
<!--
function AddRemoveCol(id, ar){
var rows=document.getElementById(id).getElementsByTagName('TR');
var zxc0,zxc2,zxccols;
for (zxc0=0;zxc0<rows.length;zxc0++){
cols=rows[zxc0].getElementsByTagName('TD');
colsnu=cols.length-1
for (zxc1=0;zxc1<=colsnu;zxc1++){
if (!cols[zxc1].set){ cols[zxc1].set='X'; }
if(cols[zxc1].style.display=='none'&&ar){
cols[zxc1].style.display='';
cols[zxc1].set='show';
break;
}
if(cols[colsnu-zxc1].style.display==''&&!ar&&cols[colsnu-zxc1].set=='show'){
cols[colsnu-zxc1].style.display='none';
cols[colsnu-zxc1].set='hide';
break;
}
}
}
}
//-->
</script>
</head>
<body>
<div class="inhalt"><a href="#self" onclick="toggle('box')" class="style3"><span class="subtitle">Availability</span></a>
<div id="box"style="display:none"><p class="style2"><strong>This article is available</strong></p>
<table style="width: 100%">
<tr>
<td style="width: 386px"><em>Packaging</em></td>
<td><em>Price</em></td>
</tr>
<tr>
<td style="width: 386px">20 pieces</td>
<td>€1.73</td>
</tr>
</table><br/>
</div>
</div>
<div class="inhalt"><a href="#self" onclick="toggle('box1')" class="style3"><span class="subtitle">Stock</span></a><div id="box1"style="display:none">
<p ><span class="bold">The following colours are in stock</span></p>
<table style="width: 100%">
<tr>
<td style="width: 386px"><em>Color</em></td>
<td><em>Location</em></td>
</tr>
<tr>
<td style="width: 386px">00</td>
<td> </td>
</tr>
</table>
<br/>
</div>
</div>
<div class="inhalt">
<a href="#self" onclick="toggle('box3')" class="style3"><span class="subtitle">Composition</span></a>
<div id="box3" style="display:none"><p ><span class="bold">Articles (Inclusive)</span></p>
<table id='id_of_table'style="width: 613px">
<tr>
<td style="width: 12px; height: 17px;"><em>N°</em></td>
<td style="display:none; height: 17px;" style="width: 102px"><em>Drawing</em></td>
<td style="width: 63px; height: 17px;"><em>Article</em></td>
<td style="width: 65px; height: 17px;"><em>Quantity</em></td>
<td style="width: 202px; height: 17px;"><em>Description</em></td>
<td style="width: 298px; height: 17px;"><em>Material</em></td>
<td style="width: 217px; height: 17px;"><em>Tolerance</em></td>
</tr>
<tr>
<td style="width: 12px; height: 15px;" valign="top"></td>
<td style="display:none; height: 15px;" style="width: 102px; height: 15px;" valign="top">
<img height="90" src="images/06577053_182429.png" width="47" /></td>
<td style="width: 63px; height: 15px;" class="copyblue" valign="top">
</td>
<td style="width: 65px; height: 15px;" valign="top"></td>
<td style="width: 202px; height: 15px;" valign="top"></td>
<td style="width: 298px; height: 15px" valign="top"></td>
<td style="width: 217px; height: 15px" valign="top"></td>
</tr>
</table>
<a href="#self" onClick= "AddRemoveCol('id_of_table', true);" ><img height="26" src="images/showhideafbeelding.jpg" style="float: right" width="26" /></a>
<a href="#self" onClick= "AddRemoveCol('id_of_table',false);" ><img height="26" src="images/showhideafbeelding.jpg" style="float: right" width="26" /></a><br/>
</div></div>
</body>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
- <html lang="NL">
- <head><title>
- Tooling
- </title>
- <script type="text/javascript" src="/scripts/swfobject.js"></script>
- <script type="text/javascript" src="/scripts/showpic.js"></script>
- <script type="text/javascript">function toggle(id) {
- var e = document.getElementById(id);
- if (e.style.display == '')
- e.style.display = 'none';
- else
- e.style.display = '';
- }
- </script>
- <script language="JavaScript" type="text/javascript">
- <!--
- function AddRemoveCol(id, ar){
- var rows=document.getElementById(id).getElementsByTagName('TR');
- var zxc0,zxc2,zxccols;
- for (zxc0=0;zxc0<rows.length;zxc0++){
- cols=rows[zxc0].getElementsByTagName('TD');
- colsnu=cols.length-1
- for (zxc1=0;zxc1<=colsnu;zxc1++){
- if (!cols[zxc1].set){ cols[zxc1].set='X'; }
- if(cols[zxc1].style.display=='none'&&ar){
- cols[zxc1].style.display='';
- cols[zxc1].set='show';
- break;
- }
- if(cols[colsnu-zxc1].style.display==''&&!ar&&cols[colsnu-zxc1].set=='show'){
- cols[colsnu-zxc1].style.display='none';
- cols[colsnu-zxc1].set='hide';
- break;
- }
- }
- }
- }
- //-->
- </script>
- </head>
- <body>
- <div class="inhalt"><a href="#self" onclick="toggle('box')" class="style3"><span class="subtitle">Availability</span></a>
- <div id="box"style="display:none"><p class="style2"><strong>This article is available</strong></p>
- <table style="width: 100%">
- <tr>
- <td style="width: 386px"><em>Packaging</em></td>
- <td><em>Price</em></td>
- </tr>
- <tr>
- <td style="width: 386px">20 pieces</td>
- <td>€1.73</td>
- </tr>
- </table><br/>
- </div>
- </div>
- <div class="inhalt"><a href="#self" onclick="toggle('box1')" class="style3"><span class="subtitle">Stock</span></a><div id="box1"style="display:none">
- <p ><span class="bold">The following colours are in stock</span></p>
- <table style="width: 100%">
- <tr>
- <td style="width: 386px"><em>Color</em></td>
- <td><em>Location</em></td>
- </tr>
- <tr>
- <td style="width: 386px">00</td>
- <td> </td>
- </tr>
- </table>
- <br/>
- </div>
- </div>
- <div class="inhalt">
- <a href="#self" onclick="toggle('box3')" class="style3"><span class="subtitle">Composition</span></a>
- <div id="box3" style="display:none"><p ><span class="bold">Articles (Inclusive)</span></p>
- <table id='id_of_table'style="width: 613px">
- <tr>
- <td style="width: 12px; height: 17px;"><em>N°</em></td>
- <td style="display:none; height: 17px;" style="width: 102px"><em>Drawing</em></td>
- <td style="width: 63px; height: 17px;"><em>Article</em></td>
- <td style="width: 65px; height: 17px;"><em>Quantity</em></td>
- <td style="width: 202px; height: 17px;"><em>Description</em></td>
- <td style="width: 298px; height: 17px;"><em>Material</em></td>
- <td style="width: 217px; height: 17px;"><em>Tolerance</em></td>
- </tr>
- <tr>
- <td style="width: 12px; height: 15px;" valign="top"></td>
- <td style="display:none; height: 15px;" style="width: 102px; height: 15px;" valign="top">
- <img height="90" src="images/06577053_182429.png" width="47" /></td>
- <td style="width: 63px; height: 15px;" class="copyblue" valign="top">
- </td>
- <td style="width: 65px; height: 15px;" valign="top"></td>
- <td style="width: 202px; height: 15px;" valign="top"></td>
- <td style="width: 298px; height: 15px" valign="top"></td>
- <td style="width: 217px; height: 15px" valign="top"></td>
- </tr>
- </table>
- <a href="#self" onClick= "AddRemoveCol('id_of_table', true);" ><img height="26" src="images/showhideafbeelding.jpg" style="float: right" width="26" /></a>
- <a href="#self" onClick= "AddRemoveCol('id_of_table',false);" ><img height="26" src="images/showhideafbeelding.jpg" style="float: right" width="26" /></a><br/>
- </div></div>
- </body>
I can show and hide textblocks by clicking on the title. I want to do more or less the same with a column in the 'composition' part of the site. I want to be able to click on an image under the table to show and hide the column 'drawing' (= the second column.) But I can't get this to work. The only solution I have so for is to use two images (one to show the column and one to hide it again). Is there a way to use just one image to get the same result? (currently the image on the right is to show the column en the left image is to hide the column)
Thanks,
Nina
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
June 21st, 2010, 2:49 am
- mindfullsilence
- Professor


- Joined: Aug 04, 2008
- Posts: 846
- Status: Offline
- natas
- PHP Ninja


- Joined: Mar 28, 2009
- Posts: 305
- Loc: AFK
- Status: Offline
There is an Ozzu tutorial for this:
javascript-tutorials/tutorial-expand-collapse-blocks-and-navigation-trees-t89202.html
javascript-tutorials/tutorial-expand-collapse-blocks-and-navigation-trees-t89202.html
Custom Web Design
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 3 posts
- Users browsing this forum: No registered users and 98 guests
- 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
