simpli Posted April 9, 2009 Share Posted April 9, 2009 Hi, I've been making some progress with the collapse of my tbody but I have one ultimate problem: Right now I can make the detail rows collapse and expand. The only problem is I want when the page load to have everything collapsed. I tried creating a function that collapses all the tbodys but it collapses EVERYTHING in sight. Apparently a table row outside a tbody is also a considered a tbody inside. How could I proceed to not hide my summary rows in the process? You can try the standalone html below to see what I mean. Also Can anyone try this in IE to tell me if it works? I'm on a mac and I have no way to test it. Thanks, Here's my code <style type="text/css"> /*tbody.corps{ display:block; }*/ </style> <script type='text/javascript'> function showHide(EL) { ELpntr=document.getElementById(EL); if (ELpntr.style.display=='none') { ELpntr.style.display=""; } else { ELpntr.style.display='none'; } } function hideall() { locl = document.getElementsByTagName('tbody'); for (i=0;i<locl.length;i++) { locl[i].style.display='none'; } } /*onload=hideall;*/ </script> <html><head><title>Resultats</title></head> <body></br><table width=400><tr> <td width=200>Nom/Choix</td><td width=50>Points</td><td width=50>Points bonis</td><td width=50>total</td></tr> <tr BGCOLOR="#99CCFF" onclick="showHide('tb_jeanru')"> <td>jeanru</td><td>0</td><td>0</td><td>0</td></tr> <tbody id='tb_jeanru' ><td>Boston en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>Washington en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>Florida en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>Philadelphie en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>Dallas en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>Minnesota en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>Calgary en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>Chicago en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>adbnmasd</td><td>0</td><td>0</td><td>0</td></tr> <td>adlkj</td><td>0</td><td>0</td><td>0</td></tr> <td>alexandre daigle</td><td>0</td><td>0</td><td>0</td></tr> <td>bnmsdoij</td><td>0</td><td>0</td><td>0</td></tr> <td>jadflkj</td><td>0</td><td>0</td><td>0</td></tr> <td>mouch</td><td>0</td><td>0</td><td>0</td></tr> <td>nmsd</td><td>0</td><td>0</td><td>0</td></tr> <td>picard</td><td>0</td><td>0</td><td>0</td></tr> <td>picouille</td><td>0</td><td>0</td><td>0</td></tr> <td>pouti</td><td>0</td><td>0</td><td>0</td></tr> <tr> <td>Roberto Luongo</td><td>0</td><td>0</td><td>0</td></tr> <td>Finaliste: San Jose</td><td>0</td><td>0</td><td>0</td></tr> <td>Finaliste: boston</td><td>0</td><td>0</td><td>0</td></tr> <td>Champion: boston</td><td>0</td><td>0</td><td>0</td></tr> </tbody> <tr BGCOLOR="#99CCFF" onclick="showHide('tb_lisa')"> <td>lisa</td><td>0</td><td>0</td><td>0</td></tr> <tbody id='tb_lisa' ><td>Boston en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>New York Rangers en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>Florida en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>Montreal en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>Dallas en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>Detroit en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>Calgary en 4</td><td>0</td><td>0</td><td>0</td></tr> <td>Vancouver en 4</td><td>0</td><td>0</td><td>0</td></tr> <td> a,mdfnlok</td><td>0</td><td>0</td><td>0</td></tr> <td> bamnbdfljk</td><td>0</td><td>0</td><td>0</td></tr> <td>adfkjl</td><td>0</td><td>0</td><td>0</td></tr> <td>adkfjl</td><td>0</td><td>0</td><td>0</td></tr> <td>aldfjlj</td><td>0</td><td>0</td><td>0</td></tr> <td>ddfasddfa</td><td>0</td><td>0</td><td>0</td></tr> <td>la,dmnfm</td><td>0</td><td>0</td><td>0</td></tr> <td>lkkjadlfjk</td><td>0</td><td>0</td><td>0</td></tr> <td>mn,adfpolk</td><td>0</td><td>0</td><td>0</td></tr> <td>nmad,mn</td><td>0</td><td>0</td><td>0</td></tr> <tr> <td>Roberto Luongo</td><td>0</td><td>0</td><td>0</td></tr> <td>Finaliste: San Jose</td><td>0</td><td>0</td><td>0</td></tr> <td>Finaliste: boston</td><td>0</td><td>0</td><td>0</td></tr> <td>Champion: boston</td><td>0</td><td>0</td><td>0</td></tr> </tbody> <tr BGCOLOR="#99CCFF" onclick="showHide('tb_maggie')"> <td>maggie</td><td>0</td><td>0</td><td>0</td></tr> <tbody id='tb_maggie' > </tbody> </table></br> </body></html> Quote Link to comment https://forums.phpfreaks.com/topic/153254-solved-tbody-collapse-second-take/ Share on other sites More sharing options...
Floydian Posted April 9, 2009 Share Posted April 9, 2009 the way I'd do it, I'd put a class on tbodies that should be collapsible. then, inside your for loop, check if the tbody has the class using locl.className If you have multiple classes on the tbody, it gets more complex, but that's the way I'd do it Quote Link to comment https://forums.phpfreaks.com/topic/153254-solved-tbody-collapse-second-take/#findComment-805342 Share on other sites More sharing options...
darkfreaks Posted April 10, 2009 Share Posted April 10, 2009 i fixed it i think try window.onload=hideall(); Quote Link to comment https://forums.phpfreaks.com/topic/153254-solved-tbody-collapse-second-take/#findComment-805981 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.