JavaScript
  Home arrow JavaScript arrow Page 3 - Bulleted Menu of Links
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Bulleted Menu of Links
By: Chrysanthus Forcha
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-04-23

    Table of Contents:
  • Bulleted Menu of Links
  • Operation from the User’s Point of View
  • Algorithm
  • Code continued
  • Even More Code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    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)

    More JavaScript Articles
    More By Chrysanthus Forcha


       · There are so many elements of bad practie put forward within this article. Using...
       · If you want the links of your web page to appear like the folder tree in Windows...
     

    JAVASCRIPT ARTICLES

    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget
    - Ajax Hack for Entering Information Without R...
    - EXT JS 2.1 Overview
    - Using the Style Object for Zebra Tables with...
    - Binary Searching
    - An Improved Approach to Building Zebra Tables
    - Assigning Background Colors Dynamically to Z...
    - Building Zebra Tables with CSS and JavaScript
    - JavaScript: Array Objects
    - A Closer Look at Smart Markers with Yahoo! M...
    - Using Polylines and Smart Markers with Yahoo...
    - Bulleted Menu of Links
    - Creating Click Loggers and Basic Markers wit...
    - Adding Pan Controls to Yahoo! Maps


    IBM developerWorks





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway