JavaScript
  Home arrow JavaScript arrow Page 3 - Switching on Layers with Scripts
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? 
JAVASCRIPT

Switching on Layers with Scripts
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 6
    2004-06-08

    Table of Contents:
  • Switching on Layers with Scripts
  • Starting with a Basic HTML Page
  • VBScript Subroutines
  • Using an Array
  • JavaScript Version

  • 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


    Switching on Layers with Scripts - VBScript Subroutines


    (Page 3 of 5 )

    VBScript is all about subroutines, small modules of script that execute independently; define the first subroutine, which is an onLoad event and sets how the page initially looks:

    sub window_onLoad()
     content1.style.visibility="hidden"
     content2.style.visibility="hidden"
     content3.style.visibility="hidden"
     content4.style.visibility="hidden"
     startmessage.style.visibility="visible"
    end sub

    Next, add the subroutine to execute if and when tab1 is clicked:

    sub tab1_onClick()
     tab1.style.zindex="3"
     tab2.style.zindex="2"
     tab3.style.zindex="1"
     tab4.style.zindex="0"
     content1.style.visibility="visible"
     content2.style.visibility="hidden"
     content3.style.visibility="hidden"
     content4.style.visibility="hidden"
     startmessage.style.visibility="hidden"
    end sub

    Repeat this subroutine another three times, one for each of the remaining tabs which the visitor/user can click:

    sub tab2_onClick()
     tab2.style.zindex="3"
     tab1.style.zindex="2"
     tab3.style.zindex="1"
     tab4.style.zindex="0"
     content1.style.visibility="hidden"
     content2.style.visibility="visible"
     content3.style.visibility="hidden"
     content4.style.visibility="hidden"
     startmessage.style.visibility="hidden"
    end sub
    sub tab3_onClick()
     tab3.style.zindex="3"
     tab1.style.zindex="2"
     tab2.style.zindex="1"
     tab4.style.zindex="0"
     content1.style.visibility="hidden"
     content2.style.visibility="hidden"
     content3.style.visibility="visible"
     content4.style.visibility="hidden"
     startmessage.style.visibility="hidden"
    end sub
    sub tab4_onClick()
     tab4.style.zindex="3"
     tab1.style.zindex="2"
     tab2.style.zindex="1"
     tab3.style.zindex="0"
     content1.style.visibility="hidden"
     content2.style.visibility="hidden"
     content3.style.visibility="hidden"
     content4.style.visibility="visible"
     startmessage.style.visibility="hidden"
    end sub

    Now just add the end comment wrapper and close off the script:

    -->
    </script>

    More JavaScript Articles
    More By Dan Wellman


     

    JAVASCRIPT ARTICLES

    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - 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...







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