Edit: http://dynamicdrive.com/dynamicindex17/ddaccordion.htm
Hey everyone,
I'm new here, so sorry if this is out-of-place or not in any correct format.
I recently installed a new menu (an Accordion menu) for my navigation. Along with that, I have a basic "Hide/Show" option to hide or show specific areas on the page, such as a certain news post, etc.
As soon as I installed the Accordion menu, the Hide/Show buttons disappeared on all pages that were using both items. I recently was checking through the code to see if any specific line was causing the problem. Here's the code:
The first script is for the Hide/Show buttons. The next four are all for the Accordion menu. After removing the "effects.js" and "prototype.js" scripts from the header, the Hide/Show buttons appeared once again, and, obviously, the accordion can't work.Code:<script type="text/javascript"> var temp, temp2, cookieArray, cookieArray2, cookieCount; function initiate(){ cookieCount=0; if(document.cookie){ cookieArray=document.cookie.split(";"); cookieArray2=new Array(); for(i in cookieArray){ cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,""); } } cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array(); temp=document.getElementById("containerul"); for(var o=0;o<temp.getElementsByTagName("li").length;o++){ if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0){ temp2 = document.createElement("span"); temp2.className = "symbols"; temp2.style.backgroundImage = (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(minus.png)":"url(plus.png)"):"url(plus.png)"; temp2.onclick=function(){ showhide(this.parentNode); writeCookie(); } temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild) temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none"; if(cookieArray[cookieCount]=="true"){ showhide(temp.getElementsByTagName("li")[o]); } cookieCount++; } else{ temp2 = document.createElement("span"); temp2.className = "symbols"; temp2.style.backgroundImage = "url(page.png)"; temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild); } } } function showhide(el){ el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block"; el.getElementsByTagName("span")[0].style.backgroundImage=(el.getElementsByTagName("ul")[0].style.display=="block")?"url(minus.png)":"url(plus.png)"; } function writeCookie(){ // Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie. cookieArray=new Array() for(var q=0;q<temp.getElementsByTagName("li").length;q++){ if(temp.getElementsByTagName("li")[q].childNodes.length>0){ if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){ cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block"); } } } document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString(); } </script> <script type="text/javascript" src="javascript/prototype.js"></script> <script type="text/javascript" src="javascript/effects.js"></script> <script type="text/javascript" src="javascript/accordion.js"></script> <script type="text/javascript"> // // In my case I want to load them onload, this is how you do it! // Event.observe(window, 'load', loadAccordions, false); // // Set up all accordions // function loadAccordions() { var topAccordion = new accordion('horizontal_container', { classNames : { toggle : 'horizontal_accordion_toggle', toggleActive : 'horizontal_accordion_toggle_active', content : 'horizontal_accordion_content' }, defaultSize : { width : 525 }, direction : 'horizontal' }); var bottomAccordion = new accordion('vertical_container'); var nestedVerticalAccordion = new accordion('vertical_nested_container', { classNames : { toggle : 'vertical_accordion_toggle', toggleActive : 'vertical_accordion_toggle_active', content : 'vertical_accordion_content' } }); // Open first one bottomAccordion.activate($$('#vertical_container .accordion_toggle')[0]); // Open second one topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[2]); } </script>
Here's the three scripts that are required for the Accordion to run (everything except the containerul.js):
http://omgclan.com/javascript/
I'm just assuming there's something in both the effects.js and prototype.js that is messing up the other code, but I'm still pretty new to javascript, so any help you can give would be awesome!
Thanks again for your time and any help you can offer!



Reply With Quote

Bookmarks