Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Expandable/Collapseing table, need help!
Old 07-13-2008, 02:56 PM Expandable/Collapseing table, need help!
Super Talker

Posts: 135
Trades: 0
First off this is not my creation, i got the original script and directions from some other site. I did however slightly modify it. I however will post the original as it is simple and i think its all thats needed to fix my problem.

What i need to know is if there is anyway that the same effect acheived with the code below can be done without using cookies? If it cannot be done this way without using cookies is there any method that will give me the same effect (starting off collapsed and allowing me to expand them) without cookies? the place im using this code will not allow me to use the code as it is because it somehow references the cookies.

heres all the code.

I had to first create a .js file with the following code in it.

Code:
/*
Expandable Listmenu Script
Author : Daniel Nolan
http://www.bleedingego.co.uk/webdev.php
*/
function initMenus() {
if (!document.getElementsByTagName) return;
var aMenus = document.getElementsByTagName("LI");
for (var i = 0; i < aMenus.length; i++) {
var mclass = aMenus[i].className;
if (mclass.indexOf("treenode") > -1) {
var submenu = aMenus[i].childNodes;
for (var j = 0; j < submenu.length; j++) {
if (submenu[j].tagName == "A") {
submenu[j].onclick = function() {
var node = this.nextSibling;
while (1) {
if (node != null) {
if (node.tagName == "UL") {
var d = (node.style.display == "none")
node.style.display = (d) ? "block" : "none";
this.className = (d) ? "treeopen" : "treeclosed";
return false;
}
node = node.nextSibling;
} else {
return false;
}
}
return false;
}
submenu[j].className = (mclass.indexOf("open") > -1) ? "treeopen" : "treeclosed";
}
if (submenu[j].tagName == "UL")
submenu[j].style.display = (mclass.indexOf("open") > -1) ? "block" : "none";
}
}
}
}
window.onload = initMenus;
After creating that file, i was to use the following code in my page...

Code:
<head>
	<title>..</title>
	<script src="listmenu.js" type="text/javascript"></script>
</head>
At which point i could use the following code to structure the collapse/expandable menus...

Code:
<ul>	<li class="treenode">		<a href="">Top Level Item</a>		<ul>			<li><a href="">List Item</a></li>			<li><a href="">List Item</a></li>			<li><a href="">List Item</a></li>			<li><a href="">List Item</a></li>		</ul>	</li></ul>
Thanks guys.
CompTronicsTec is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-13-2008, 07:56 PM Re: Expandable/Collapseing table, need help!
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
I don't see anywhere in this example where cookies are being used.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Expandable/Collapseing table, need help!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09707 seconds with 12 queries