View Full Version : Accordion Menu: Passing A Parameter To Open A Menu Header (not in the url)

04-30-2008, 08:45 AM
1) Script Title: Accordion Menu script (v1.3)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu.htm

3) Describe problem: Is there a way of setting which menu header opens on a page without passing a parameter in the url?

I've added the following link the page and when clicked the 1st menu header opens, which is great but I don't want to have to click the link. I've tried adding this to the onload event of the body tag but this doesn't work. Any ideas?

<a href="#" onClick="ddaccordion.expandone('expandable', 0); return false">Expand 1st header</a>

05-01-2008, 02:19 AM
Two ways. Firstly, you can set the defaultexpanded parameter within initialization code to specify which header(s) should be expanded by default. Or on the same page, you can call functions like:

ddaccordion.expandone('header_class', index)

to expand a header. Basically all the methods listed in the first table here (http://www.dynamicdrive.com/dynamicindex17/ddaccordion_suppliment.htm).

05-02-2008, 07:50 AM
I need to pass a parameter at the start of each page to this function ddaccordion.expandone('header_class', index).

However I do not want to add an onClick event. I've tried calling this function on the onLoad event for the body but it doesn't work.

Any ideas? I want to run the function after the page loads without the need to click a link etc.

05-03-2008, 01:44 AM
There's no reason why you can't call ddaccordion.expandone('header_class', index) automatically, such as when the page loads:

<body onload="ddaccordion.expandone('myheader', 1)">

for example. If you're trying to pass a parameter to get a particular header to expand, there's no point, since the prebuilt "index" parameter above is used just for that- passing in 1 for example means the 2nd header would expand.