I am trying to install a accordion side menu onto a page and am having some issues. Not knowing javascript isn't helping. The script and setup is from http://dynamicdrive.com/dynamicindex17/ddaccordionmenu-glossy.htm. The page that I am testing the dropdown on is engineeringtshirts.com I am having issues in 2 parts. First, I want the previous state of the pull downs to be reset on page refresh. Right now if you have the 3rd pull down open and refresh, the third pull down will still be open even though the default is set to the second pull down. The second part that I am having trouble with is setting the defaultexpanded page by page. I want/have the main function and menu layout being pulled from additional php files (so I can update the menu and links in one file instead of 40 files later). I have found a way to declare a php variable as a value on an individual page then inject the php variable into the defaultexpanded section (shown below). I am wondering how to do the same thing in javascript. <?php $currentexpand=2; ?> then in the javascript ddaccordion.init defaultexpanded: [<?php echo $currentexpand ?>], Code (markup):
It is set through a cookie. I think they provide a way to handle this behavior: Try setting persiststate: false, PHP: instead of true ?
Yeah, just saw that. I dont know how I missed that earlier. How do I declare and set a variable then have it in the defaultexpanded: [variable],
Hi ziplock122949, I think it is possible to just put a js var there. And controlling the var is possible e.g through URL GET (assuming the filename as current.htm): http://engineeringtshirts.com/current.htm?[COLOR="red"]def_exp[/COLOR]=x Code (markup): where x is defaultexpanded number, passed into that URL. To have this, add a piece of code on top: <script type="text/javascript"> if (location.search.length > 0){ var get_params = location.search.substr(1).split("="); if ((get_params.length === 2) && (get_params[0] === "[COLOR="red"]def_exp[/COLOR]" )) [COLOR="red"]def_exp[/COLOR] = get_params[1]; else [COLOR="red"]def_exp[/COLOR] = ""; } else{ [COLOR="red"]def_exp[/COLOR] = ""; } ddaccordion.init({ headerclass: "submenuheader", ... defaultexpanded: [[COLOR="red"]def_exp[/COLOR]], ... Code (markup):
Well i'm stupid. I was not looking for the url part, but i your response did help me recognize something that I passed over, I was not setting the variable BEFORE the ddaccordion.init. Thanks for the help.