HTML
  Home arrow HTML arrow Completing a 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  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
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? 
HTML

Completing a Bulleted Menu Of Links
By: Chrysanthus Forcha
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2009-03-02

    Table of Contents:
  • Completing a Bulleted Menu Of Links
  • The expandOrCollapse(leftIDpart, rightIDpart) Function
  • Global Variables
  • Still on Second Level Event
  • Other List-Item Markers

  • 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


    Completing a Bulleted Menu Of Links


    (Page 1 of 5 )

    In the previous part of this two-part tutorial, I began describing how to build a bulleted menu of links, such as you might see on many web sites. These links unfold, so that some headings, when clicked, reveal links below them to pages that are subcategories. In this second part, I will jump right back into the subject, starting with the JavaScript code we need to accomplish the magic.

    The JavaScript Code

    Each ID is made up of two parts: the left part, which is either LI or UL; and the right part, which is a number. When any LI element that is expandable is clicked, the function “splitID(ID)” is called. This function splits the ID into two parts, throwing away the underscore. The function is:


    function splitID(ID)

    {

    IDPartsArr = ID.split("_");

     

    //call the function to expand or collapse the unordered list

    expandOrCollapse(IDPartsArr[0], IDPartsArr[1]);

    }


    When you click an expandable link, it calls the function, sending its ID as argument. JavaScript has a string method called split(separator). The method splits a string based on a separator and discards the separator. You use the method with the string function as follows:


    stringObject.split(separator)


    So, for example, if the string object is “LI_11,” the result will be two sub strings, which are “LI” and “11.” The underscore is discarded. In our example above, the ID is the string object. An array is returned by the JavaScript method. The elements of the array are the spitted sub strings. In our example, the array is held by the IDPartsArr variable. In our project, this array will always have two elements: the first one, “LI” or UL, and the second one, a number.

    Lastly, this function calls another function, “expandOrCollapse().” The first argument of this function is the first element of the IDPartsArr array. The second argument of the function is the second element of the IDPartsArr array.

    More HTML Articles
    More By Chrysanthus Forcha


     

    HTML ARTICLES

    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers
    - Downloading Long HTML Pages with ACP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek