View Full Version : Can onopenclose() cause a main content area to disappear/appear?

03-17-2009, 01:14 AM
1) Accordion Content script (v1.6)

2) http://dynamicdrive.com/dynamicindex17/ddaccordion.htm

3) Describe problem:

I would like the action of a user opening a header up to change which <div> is displayed in the main content area. The idea is that when the page loads, all accordiaons are closed and the main text displays a separate paragraph (ie a separate <div> section) relevent to each header. When a header is clicked to open it, only its its relevent paragraph remains displayed in the maintext area. The accordion's links then act as normal.

03-17-2009, 04:59 AM
Certainly. What you put inside onopenclose() is not limited to just code that affects the menu itself, and outside of it as well.

In your case, try giving each header a unique ID, such as "header1", then for the corresponding paragraph, a ID based on the former so the two can easily be linked together, such as "para-header1". Then inside your onopenclose() event, do something like:

onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
var paraid="para" + header.id
document.getElementById(paraid).style.display=(state=="block")? "block" : "none"

What the above does is expand or hide paragraph "para-headerx" based on the corresponding header's own state.

03-17-2009, 08:28 PM
Made the changes as you suggested and it all works well, doing exactly what I needed. Until the client asks for yet another "small change.......".
Thanks again for a great facility, made brilliant by your quick and helpful answers.