|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
Collapsing table
Alright, here;s what I need, I have this table, and I want to collapse it. What I have at this point is this JavaScrip:
Code:
<Script Language=JavaScript>
var oldStuff=new Array();
oldStuff[0]=document.getElementById('2');
oldStuff[1]=document.getElementById('2').outerText;
function collapse()
{
oldStuff[0]=document.getElementById('2');
oldStuff[1]=document.getElementById('2').innerHTML;
var theRow=document.getElementById('2');
var theLink=document.getElementById('excol1');
theRow.outerText="";
theLink.outerHTML="<a href="javascript:expand()">-</a>";
}
function expand()
{
var theRow=oldStuff[0];
theRow.innerHTML=oldStuff[1];
}
</script>
Collapse works as expected, the table row disappears, and moves the previous row up into its place. expand does not work. When i do alert(theRow.innerHTML); I get what should be there, both before and after, but it never shows back up on my page. Any way I can make this work? Am I going about it at the wrong approach?? Edit: Ok, so I get part of my problem, you can't write a full string to innerHTML on table like objects, so the solution I read said wrap it in a div, well, when I do alert(document.getElementById('part1').innerHTML); I get a blank. In the HTML I have <div id="part1"> ......(table code here)...... </div> It should show the table code should it not? |
|
#2
|
|||
|
|||
|
RE: Collapsing table
you can show/hide any html element by altering its style.display property. to hide:
element.style.display = "none"; and to show later: element.style.display = "block"; |
|
#3
|
|||
|
|||
|
RE: Collapsing table
Now, the above works great to hide it, but it still won't show back up again
|
|
#4
|
|||
|
|||
|
RE: Collapsing table
ah, sorry, table row has something other than "block". it is not a "normal" element. ;)
try adding alert(tr.style.display) before you hide it to check that value (it will be somehting like "table-row" or similar) and than replace "block" with that new value.. |
|
#5
|
|||
|
|||
|
RE: Collapsing table
whoops, sorry, you were right, I misspelled block :p
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Collapsing table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|