Results 1 to 4 of 4

Thread: Accordion Menu: Passing A Parameter To Open A Menu Header (not in the url)

  1. #1
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Accordion Menu: Passing A Parameter To Open A Menu Header (not in the url)

    1) Script Title: Accordion Menu script (v1.3)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ordionmenu.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>

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    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:

    Code:
    ddaccordion.expandone('header_class', index)
    to expand a header. Basically all the methods listed in the first table here.

  3. #3
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    There's no reason why you can't call ddaccordion.expandone('header_class', index) automatically, such as when the page loads:

    Code:
    <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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •