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  
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? 
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

    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in
    - Active Client Pages at the Server
    - ACP Tab Web Page







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT