View Full Version : Accordion Expanding/Collapsing Issue

03-17-2008, 07:48 PM

I have a php page which dynamically creates divs for the accordion based off data from a xml document. The functionality of the accordion works perfectly on this page including the hyperlinks I added to expand and collapse certain headers.

This page contains an iframe that links to information from a seperate html document. The problem I am having is trying to setup links in this external html document that will expand/collapse the headers from my main php page.

It seems to me that since the js function(ddaccordion.toggleone) is initated from the html document, it tries to reference the header classes from within the html document.

Is it possible to call the ddacordion.toggleone function from within an iframe but have it reference the css class information from my main php page?

Thanks in advance for your reply.

03-17-2008, 11:14 PM
Warning: Please include a link to the DD script in question in your post, in this case: http://www.dynamicdrive.com/dynamicindex17/ddaccordion.htm . See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.

Well, you're right that when you call something like:

<a href="#" onClick="ddaccordion.toggleone('mypets', 1); return false">Toggle 2nd header</a>

"mypets" is assumed to be a CSS class on the page the link is contained in. If this link is in an IFRAME but the Accordion menu it manipulates is in the parent document, what you should instead is first to make sure the Accordion Menu is installed on your main parent document and properly initialized, then try to call it directly from the IFRAME page, something like:

<a href="#" onClick="parent.ddaccordion.toggleone('mypets', 1); return false">Toggle 2nd header</a>