[javascript] Question

S.F. Alim salim at vodatel.com
Sun Jul 31 00:55:40 CDT 2005


Hi,
Well what I am going to tell you might not be an answer but it might help u
in some way, first of all I am not a javascripter, just a simple css
designer.

Some one wrote me this javascript just like you

if (style2.display == "block")
 {style2.display = "none";}
else
 {style2.display = "block";}


But for css I have to make element/selector[#left-column] display:none;
then your script will work on first click.

Otherwise like Mr. Matt said

"Since it's empty, it gets thrown into your else condition".

Regards,
S. F. Alim
Information Unit




-----Original Message-----
From: javascript-bounces at LaTech.edu [mailto:javascript-bounces at LaTech.edu]On
Behalf Of Schalk Neethling
Sent: Sunday, July 31, 2005 2:45 AM
To: javascript at LaTech.edu
Subject: [javascript] Question

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.

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript






More information about the Javascript mailing list