Home arrow JavaScript arrow Page 3 - Bulleted Menu of Links
JAVASCRIPT

Bulleted Menu of Links


In this article, I will be going over the various features of a bulleted menu of links, including how to implement them in your web page. All explanations will be accompanied by code samples to help you through this process. If you want to learn more about this common web page function, then, by all means, keep reading.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
April 23, 2008
TABLE OF CONTENTS:
  1. · Bulleted Menu of Links
  2. · Operation from the User’s Point of View
  3. · Algorithm
  4. · Code continued
  5. · Even More Code

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Bulleted Menu of Links - Algorithm
(Page 3 of 5 )

The algorithm for the complete JavaScript code is as follows:

When you click a bullet, the list item either expands or collapses. When the list item does not have a sub-list, nothing happens when you click its bullet. Note, in this example, that only the First Level and Second Level links can be expanded. Now each first level or second level link has a global variable associated with it in the JavaScript. Each of the variables can either take the value “Expand” or “Collapse” to indicate whether the list item is able to be expanded or collapsed. Any list item that does not have a sub-list does not need this corresponding variable. Note that the last level of link items are not expandable.

There are also three global string variables, one for each First Level Link list item. There are also three functions, one for each First Level Link (list item). Each function creates a string made up of its First Level Link list item along with the list items of any of its expansions. The function does this beginning with the third (last) level, then the second level, and finally the first level. Each function is placed below the global variables.

When a function is called, it first creates strings of the list items of the third (last) level links; these strings may or may not be needed. It then verifies which second level or first level list item was clicked by checking the ID. If this list item was already expanded, it gives its corresponding global variable the opposite value, which is “Collapse.” If the list item was already collapsed, it gives the corresponding opposite global variable, “Expand.” The function then creates strings for the second level list items depending on the values: Expand or Collapse. It adds these strings to any string in the third level items that might have been created. The function adds the resulting string to the first level global string.

Note: when a bullet is clicked anywhere in a chain (expansion), only one global (first level) string is affected; namely, the one that has the bullet in its chain. The other two global strings are not affected. The last thing a function does is combine its global string with the other two global strings. This way, processing time is reduced, since the other two global strings do not have to be changed.

Finally, the function sets the content of the table cell with the DOM innerHTML property. Below I give the code mainly for the First Level Link 1 in order to avoid taking up too much space:


<html>


<head>

<script type = "text/javascript">

var FLL1Direction = ""; //to expand or to collapse global variable for First Level Link 1

var SLL11Direction = ""; //to expand or to collapse global variable for Second Level Link 11

var SLL12Direction = ""; //to expand or to collapse global variable for Second Level Link 12

var SLL13Direction = ""; //to expand or to collapse global variable for Second Level Link 13


//global First Level strings

var string1 = "<li onclick="formString('FLL1')" id="FLLLI1" style='list-style-type: disc' title="Click Bullet to Expand"><a href='www.somePage1.com' id="FLL1" title='Click Bullet to Expand'>First Level Link 1</a></li>";

var string2 = "<li><a href='www.somePage2.com' title='Click Bullet to Expand'>First Level Link 2</a></li>";

var string3 = "<li><a href='www.somePage3.com' title='Click Bullet to Expand'>First Level Link 3</a></li>";


//to form string

function formString(ID)


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials