Design Usability
  Home arrow Design Usability arrow Page 2 - Create Great JavaScript and CSS Menus Simp...
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  
Moblin 
JMSL Numerical Library 
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? 
DESIGN USABILITY

Create Great JavaScript and CSS Menus Simply
By: Stephen Davies
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 5
    2007-09-18

    Table of Contents:
  • Create Great JavaScript and CSS Menus Simply
  • A Combo Box
  • Rollover Menu Example
  • Alternative Design Idea with CSS

  • 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


    Create Great JavaScript and CSS Menus Simply - A Combo Box


    (Page 2 of 4 )

    First I'll show you a quick combo box with options that open different web sites. This is one of the simplest applications using the JavaScript hierarchy to point to the items in a combo box. When JavaScript menus first started to appear, combo boxes were the earliest choices. They are quite nifty little ideas and can really aid the layout of the page. They do not occupy a particularly large portion of the page. Also, a JavaScript menu allows for several combo boxes to be placed into something like a table row quite easily or separated using DIV tags. The uses for this pretty standard method of creating a JavaScript menu are endless, really, and still popular.

    <script type="text/javascript">
    <!--

    function jsMenu(combobox){
     
    var URL=document.combobox.selection.options
    [document.combobox.selection.selectedIndex].value;
     
    window.location.href=URL;
    }

    //-->
    </script>

    Usage of hierarchy to point to data is shown here. A variable called URL will store the web page address being selected in the combo box. The document object points to the form name of combobox. Inside the form, there is the combo box itself containing the various drop-down options. The combo box needed to be named so that the hierarchy works; it is called selection. So we have:

    document.combobox.selection.options[....]

    Next, the combo box items need to be selected. The combo box named selection points to the option highlighted by the user through options. Then selectedindex is the selected option in the combo box. So:

    document.combobox.selection.options
    [document.combobox.selection.selectedIndex].value

    Now the script just needs to be applied to the form where the combo box has been inserted.

    <form name="combobox1">
     
    <select name="selection" size="1" style="background-
    color:#663399;font-family:Arial;font-size:12;color:#FFFF00;">
       
    <option value="page4.html">Open Page 4
       
    <option value="page3.html">Open Page 3
        
    <option value="page2.html">Open Page 2
       
    <option value="page1.html">Open Page 1
     
    </select>
     
    <input type="button" value="Visit Site"
    onClick="javascript:jsMenu(this)"style=" background-
    color:#663399;color:#FFFF00;font-family:Arial;font-size:12;">
    </form>

    So, a little combo box refresher. The options in the combo box can be edited very easily so go ahead. They show as single page names -- page1, page2, etc. It is very likely to be this way on a web site though URLs can also be inserted into those lines instead to open other web sites. An inline style has been used here twice. The first is used in the select tag line to style the combo box colors and fonts. The second is in the form button line to add a unique style to the button. This is what is great about inline styles as they can edit small parts of a site and override any styles attached to the site. What is achieved here is a quick and easily edited combo box.

    Menu systems work well like this on many sites. Take a look at most travel booking sites; there are usually many combo boxes for destinations, departure times and airlines. The list of uses goes on, and they are great ways to add a variety of options for interactivity to any web site.

    More Design Usability Articles
    More By Stephen Davies


       · This solution does not appear to work in IE6. The "popup" menus do not appear, and...
       · No only does this not work in ie - which is a bit of a drawback ! but the whole...
     

    DESIGN USABILITY ARTICLES

    - Create Great JavaScript and CSS Menus Simply
    - Design Principles that Shape a Web Site
    - Creating Aqua Style Images
    - Easy as A,B,C – dynamic A to Z indexes
    - EasyChart: a Usability Teaching Tool to Demo...
    - Building Friendly Pop-up Windows
    - Back to School: Design Usability
    - Using HTML_QuickForm To Manage Web Forms, Pa...
    - Using HTML_QuickForm To Manage Web Forms, Pa...
    - More Website Knick Knack
    - Browsers as Test Platforms
    - Website Knick Knack
    - Dynamic Page Elements-Cloak and Dagger Web D...
    - Accessibility and Dreamweaver MX 2004







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