| | |
Expand/Callapse All Help!
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2008
Posts: 3
Reputation:
Solved Threads: 0
Hello,
I woould like to add 2 links to this code. One to "expand all" panels and the other to "callapse all". Also, when they expand and callapse all, the plus and minus images change accordingly. Can anyone please help?
I woould like to add 2 links to this code. One to "expand all" panels and the other to "callapse all". Also, when they expand and callapse all, the plus and minus images change accordingly. Can anyone please help?
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <br> <style> #tables .tableMainSub {color: #517191; font-family: arial, helvetica, sans-serif; font-size: 11px; line-height: 18px; font-weight: normal; background: #D3DCEE; text-indent: 10px; vertical-align: middle; height: 20px; border: 1px solid #9FB9D6; cursor: hand; width:100%;} #tables .tableCellLeft {vertical-align:top; border: #9FB9D6 solid 1px; color: #000000; font-family: arial, helvetica, sans-serif; font-size: 11px; font-weight: normal; padding:5px; } </style> </head><body onLoad="initPanels();"> <span style="float:right; margin-bottom:3px; color:#999" class="sz10"><a href="javascript:void(0);" onClick="">Expand all</a> | <a href="javascript:void(0);" onClick="">Collapse all</a></span> <!--Start Accordion--> <div id="tables"> <table id="paneltable" border="0" cellpadding="1" cellspacing="1" width="100%"> <tr valign="top"> <td class="tableMainSub" onClick="ToggleRowVisibility('paneltable',1);"><img src="http://javascript.cooldev.com/scripts/cooltree/demos/lines/img/e.gif" name="paneltable.1" border="0" > Header 1</td> </tr> <tr valign="top"> <td class="tableCellLeft"><!--Start Accordion Content--> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. <!--End Accordion Content--> </td> </tr> <tr valign="top"> <td class="tableMainSub" onClick="ToggleRowVisibility('paneltable',3);"><img src="http://javascript.cooldev.com/scripts/cooltree/demos/lines/img/e.gif" name="paneltable.3" border="0" > Header 2</td> </tr> <tr valign="top"> <td class="tableCellLeft"><!--Start Accordion Content--> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. <!--End Accordion Content--> </td> </tr> <tr valign="top"> <td class="tableMainSub" onClick="ToggleRowVisibility('paneltable',5);"><img src="http://javascript.cooldev.com/scripts/cooltree/demos/lines/img/e.gif" name="paneltable.5" border="0" > Header 3</td> </tr> <tr valign="top"> <td class="tableCellLeft"><!--Start Accordion Content--> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. <!--End Accordion Content--> </td> </tr> </table> <!--End Accordion--> </div> <script> <!-- function initPanels() { // Pre-collapse some panels, as an example (assumes all panels initially visible) ToggleRowVisibility("paneltable",1); ToggleRowVisibility("paneltable",3); ToggleRowVisibility("paneltable",5); } imgExpand = new Image(); imgCollapse = new Image(); imgExpand.src = "http://javascript.cooldev.com/scripts/cooltree/demos/lines/img/c.gif"; imgCollapse.src = "http://javascript.cooldev.com/scripts/cooltree/demos/lines/img/e.gif"; </script> <script> // Panel Functions ///////////////////////////////////////////////////////////////////////////////////////////////////// function ChangeRowVisibility(tableName, strVisibility, intRowIndex) { if(strVisibility == "visible") { document.getElementById(tableName).rows[intRowIndex].style.display = "block"; } else if(strVisibility == "collapse") { document.getElementById(tableName).rows[intRowIndex].style.display = "none"; } } function ToggleRowVisibility(tableName, intRowIndex) { var currentSetting = document.getElementById(tableName).rows[intRowIndex].style.display; if (currentSetting=="none") { ChangeRowVisibility(tableName,"visible", intRowIndex); document.images[tableName+"."+intRowIndex].src=imgCollapse.src; } else { ChangeRowVisibility(tableName,"collapse", intRowIndex); document.images[tableName+"."+intRowIndex].src=imgExpand.src; } } </script> </body> </html>
The easiest way is to create a new function on you JS code, simple as
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function exall() { for (inde=1;inde<=5;inde=inde+2) { ToggleRowVisibility("paneltable",inde); } }
You keep going, have a Nice day!
Henry.
Before printing this message, make sure is necessary.
Henry.
Before printing this message, make sure is necessary.
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: check javascript is enabled!!!
- Next Thread: Problem during custom scroll
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box browser bug calendar captchaformproblem cart close codes column cookies css date debugger decimal dependent design disablefirebug dom download element embed engine enter error events ext file firefox focus form frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 iframe index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp libcurl listbox maps masterpage media menu microsoft mimic mp4 onmouseoutdivproblem onmouseover paypal pdf php player position post problem programming prototype redirect regex safari scale scriptlets scroll search security select software sql text textarea toggle unicode variables w3c website window windowofwords windowsxp





