View Full Version : How to make a folding box in javascript

02-07-2007, 06:53 PM
Hello there. I'm quite new to this forum but I have a pressing problem that has bugged me for quite some time...
I want to make a folding box where to put some text or some visitor counters made with php. I want to be able to click a plus button or something and the box to fold down. Like the tree menus in windows... or something.
Basicaly i want to be able to view the contents of the box and then to fold down the respective area... I want to put multiple things in that area... like a picture or something...
Does anyone know how this is done?

02-07-2007, 08:14 PM
I know how to do this, but perhaps you should try writing some code first....people will appreciate you around here more if you at least make an attempt...

Google can also be very helpful: http://www.google.com/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=nHX&q=javascript+collapse+content&btnG=Search

02-08-2007, 12:39 AM
Why couldn't you just give me a simple example? why do you think i've posted here in the first place? Don't you think thai i haven't looked into google first? I've posted here because i want a concrete example man... Can you or can you not give me one... ?

02-08-2007, 01:49 AM
Well, man, if you click on the Google link I posted in my previous post and scroll down the first page to this result:

DHTML expand and collapse div menu (http://www.google.com/url?sa=t&ct=res&cd=9&url=http%3A%2F%2Fwww.dustindiaz.com%2Fdhtml-expand-and-collapse-div-menu%2F&ei=WHHKRZXlDJ34hAPQ_MygDA&usg=__iBdc7kUEAv9uOz6eGY_RO4WAsMc=&sig2=pmkHBWSjvjw7i9PMJ7mCxQ)

You can collapse them by default, but if you do so then users who have Javascript disabled will never be able to see your content. ...
www.dustindiaz.com/dhtml-expand-and- (http://www.dustindiaz.com/dhtml-expand-and-)collapse-div-menu/ - 76k -Cached ( - Similar pages (http://www.google.com/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla:en-US:official&pwst=1&q=related:www.dustindiaz.com/dhtml-expand-and-collapse-div-menu/)

Then point your mouse at the link and click on it, you will find a page that explains one way to create an expandable/collapsable box like you are describing.

They even go so far as to provide you with an example here: http://www.dustindiaz.com/basement/block-toggle.html.

02-09-2007, 01:14 PM
thank you very much
you have been very helpful