Show/hide column

  • Nina07
  • Born
  • Born
  • Nina07
  • Posts: 2

Post 3+ Months Ago

Hi,

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>&nbsp;</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>
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
  2. <html lang="NL">
  3. <head><title>
  4.     Tooling
  5. </title>
  6.  
  7.   
  8.   <script type="text/javascript" src="/scripts/swfobject.js"></script>
  9.   <script type="text/javascript" src="/scripts/showpic.js"></script>
  10.   <script type="text/javascript">function toggle(id) {
  11.  var e = document.getElementById(id);
  12.  if (e.style.display == '')
  13.   e.style.display = 'none';
  14.  else
  15.   e.style.display = '';
  16. }
  17. </script>
  18. <script language="JavaScript" type="text/javascript">
  19. <!--
  20. function AddRemoveCol(id, ar){
  21. var rows=document.getElementById(id).getElementsByTagName('TR');
  22. var zxc0,zxc2,zxccols;
  23. for (zxc0=0;zxc0<rows.length;zxc0++){
  24.  cols=rows[zxc0].getElementsByTagName('TD');
  25.  colsnu=cols.length-1
  26.  for (zxc1=0;zxc1<=colsnu;zxc1++){
  27.   if (!cols[zxc1].set){ cols[zxc1].set='X'; }
  28.   if(cols[zxc1].style.display=='none'&&ar){
  29.   cols[zxc1].style.display='';
  30.   cols[zxc1].set='show';
  31.   break;
  32.   }
  33.   if(cols[colsnu-zxc1].style.display==''&&!ar&&cols[colsnu-zxc1].set=='show'){
  34.   cols[colsnu-zxc1].style.display='none';
  35.   cols[colsnu-zxc1].set='hide';
  36.   break;
  37.   }
  38.  }
  39. }
  40. }
  41. //-->
  42. </script>
  43. </head>
  44. <body>
  45.                         
  46. <div class="inhalt"><a href="#self" onclick="toggle('box')" class="style3"><span class="subtitle">Availability</span></a>
  47. <div id="box"style="display:none"><p class="style2"><strong>This article is available</strong></p>
  48.     <table style="width: 100%">
  49.         <tr>
  50.             <td style="width: 386px"><em>Packaging</em></td>
  51.             <td><em>Price</em></td>
  52.         </tr>
  53.         <tr>
  54.             <td style="width: 386px">20 pieces</td>
  55.             <td>€1.73</td>
  56.         </tr>
  57.         </table><br/>
  58.     
  59.         
  60.     </div>
  61.         </div>
  62. <div class="inhalt"><a href="#self" onclick="toggle('box1')" class="style3"><span class="subtitle">Stock</span></a><div id="box1"style="display:none">
  63. <p ><span class="bold">The following colours are in stock</span></p>
  64. <table style="width: 100%">
  65.         <tr>
  66.             <td style="width: 386px"><em>Color</em></td>
  67.             <td><em>Location</em></td>
  68.         </tr>
  69.         <tr>
  70.             <td style="width: 386px">00</td>
  71.             <td>&nbsp;</td>
  72.         </tr>
  73.         </table>
  74.     <br/>
  75.     
  76.         </div>
  77.     </div>  
  78.     <div class="inhalt">
  79. <a href="#self" onclick="toggle('box3')" class="style3"><span class="subtitle">Composition</span></a>
  80. <div id="box3" style="display:none"><p ><span class="bold">Articles (Inclusive)</span></p>
  81.     <table id='id_of_table'style="width: 613px">
  82.         <tr>
  83.             <td style="width: 12px; height: 17px;"><em>N°</em></td>
  84.             <td style="display:none; height: 17px;" style="width: 102px"><em>Drawing</em></td>
  85.             <td style="width: 63px; height: 17px;"><em>Article</em></td>
  86.             <td style="width: 65px; height: 17px;"><em>Quantity</em></td>
  87.             <td style="width: 202px; height: 17px;"><em>Description</em></td>
  88.             <td style="width: 298px; height: 17px;"><em>Material</em></td>
  89.             <td style="width: 217px; height: 17px;"><em>Tolerance</em></td>
  90.         </tr>
  91.         <tr>
  92.             <td style="width: 12px; height: 15px;" valign="top"></td>
  93.             <td style="display:none; height: 15px;" style="width: 102px; height: 15px;" valign="top">
  94.             <img height="90" src="images/06577053_182429.png" width="47" /></td>
  95.             <td style="width: 63px; height: 15px;" class="copyblue" valign="top">
  96.             </td>
  97.             <td style="width: 65px; height: 15px;" valign="top"></td>
  98.             <td style="width: 202px; height: 15px;" valign="top"></td>
  99.             <td style="width: 298px; height: 15px" valign="top"></td>
  100.             <td style="width: 217px; height: 15px" valign="top"></td>
  101.         </tr>
  102.         </table>
  103.         <a href="#self" onClick= "AddRemoveCol('id_of_table', true);" ><img height="26" src="images/showhideafbeelding.jpg" style="float: right" width="26" /></a>
  104.         <a href="#self" onClick= "AddRemoveCol('id_of_table',false);" ><img height="26" src="images/showhideafbeelding.jpg" style="float: right" width="26" /></a><br/>
  105.             </div></div>
  106. </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
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

Maybe consider some jQuery for this, might make it easier.
Check out this plugin:
ColumnManager
  • natas
  • PHP Ninja
  • Proficient
  • natas
  • Posts: 308
  • Loc: AFK

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 57 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.