[javascript] Question

Schalk Neethling schalk at volume4.com
Sat Jul 30 18:45:09 CDT 2005


Greetings All!

I have the following bit of javascript:

-- Not posting all just the standards part --
function toggleLayer(whichLayer, expandedLayer)
{
    if (document.getElementById)
    {
        // this is the way the standards work
        var style2 = document.getElementById(whichLayer).style;
        var expander = document.getElementById(expandedLayer).style;    
               
       
        if(style2.display == "block") {
            style2.display = "none";
        } else {
            style2.display = "block";
        }
       
        if(expander.width == "50%") {
            expander.width = "75%";
        } else {
            expander.width = "50%";
        }
    }
   
Now, I have a link as such which calls the script:
<a href="javascript:toggleLayer('left-column', 'center-column');" 
title="Expand/Contract Content">Expand/Contract Content</a>

The I have the following CSS:
#left-column {
    position: relative;
    float:left;
    display:block;
    width:25%;
}

#center-column {
    position:relative;
    float:left;   
    width:50%;
   
}

Now, after all that. The problem is, the first time I click the link 
nothing happens. After that it works perfectly. I am new to javascript 
and I am sure I am overlooking something. Any help or pointers will be 
much appreciated. Thank you in advance!

-- 
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
emotionalize.conceptualize.visualize.realize
Landlines
Tel: +27125468436
Fax: +27125468436
Web
email:schalk at volume4.com
Global: www.volume4.com
Messenger
Yahoo!: v_olume4
AOL: v0lume4
MSN: volume4_ at hotmail.com

We support OpenSource
Get Firefox!- The browser reloaded - 
http://www.mozilla.org/products/firefox/

This message contains information that is considered to be sensitive or 
confidential and may not be forwarded or disclosed to any other party 
without the permission of the sender. If you received this message in 
error, please notify me immediately so that I can correct and delete the 
original email. Thank you.




More information about the Javascript mailing list