| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Registered User
Join Date: Nov 2007
Posts: 72
|
expand and collapse
Hi Say i have a page in sections eg: Pictures, Music, Videos How can i be able to expand and collapse each section so that it wont take much space on a page. Am not sure how to explain this properly so ill try a diagram below: Pictures Music Videos NOW - how can i make it so if i click Pictures for example it expands and shows every thing there without like loading a whole new page? So something like this: Pictures bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla Music Videos Thanks |
|
|
|
|
|
#2 (permalink) |
|
Registered User
Join Date: Nov 2007
Posts: 72
|
I found this script but am not sure how I would edit it so that i can use it for 3 different expand and collapse menus. Is there anyone who can show me an example with that code? <body> Some text before <div id=tbl name=tbl style="overflow:hidden;display:none"> <table border=1> <tr><td>test</td></tr> <tr><td>test</td></tr> <tr><td>test</td></tr> </table> </div> some text after <script language="JavaScript" type="text/javascript"> <!-- function sizeTbl(h) { var tbl = document.getElementById('tbl'); tbl.style.display = h; } // --> </script> <br> <a href="javascript:sizeTbl('none')">Hide</a> <a href="javascript:sizeTbl('block')">Expand</a> </body> |
|
|
|
#3 (permalink) |
|
Everything is fine.
|
For this to work as you want with multiple tables or div's you'd need to send the id of the element that you wish to expand/collapse to the JavaScript function. That way you can use one function to control many elements by passing a reference to it. - Mike |
|
|
|
#4 (permalink) |
|
Senior Member
Join Date: Feb 2008
Posts: 151
|
you also need to decide if you want the one you've just expanded to close the previously expanded one or for the old one to stay open too once you put in your divs, try ike something this blog.movalog.com/a/javascript-toggle-visibility/ |
|
|
|
#10 (permalink) | |
|
Senior Member
|
Quote:
|
|
|
|
|
#11 (permalink) | |
|
Floating libation anyone?
|
Quote:
Too bad it went largely ignored here. fun: HGC v.4 | last.fm: DT | me | oi! f*ck u roto: ...via meebo!
New to interweb design? Your friends at dt can help. |
|
|
|
|
#14 (permalink) |
|
Registered User
Join Date: Nov 2007
Posts: 72
|
Ok i got it working but could someone clean the html up for me please? heres the code: Code:
|
|
![]() |