View Single Post
04-30-2008, 06:27 PM
#1
Seanneo is offline Seanneo
Status: Junior Member
Join date: May 2007
Location:
Expertise:
Software:
 
Posts: 26
iTrader: 1 / 100%
 

Seanneo is on a distinguished road

  Old  Javascript Divs!

Hey guys,
I was just wondering if anyone would be able to help me... Im trying to create a script that when a button is clicked, the height of a div changes.
I want the height to count down from the max height down to zero(so its invisible), i have written a script that does this but i cant seem to add a delay into it, so it does change size so fast you cant see it change size.
Would appreciate help!

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Expanding Divs</title>
<style type="text/css">
    #expand {
        background-color: blue;
        color: white;
    }
</style>
<script type="text/javascript">
<!--
var hValue = 300;

function divSize()
{
    var element = document.getElementById("expand");
    while(hValue>0)
    {
        heightChange(element, hValue);
        hValue = hValue - 1;
        //alert(hValue);
    }
}
function heightChange(element, hValue)
{
    element.style.height = ""+hValue+"px";
}
-->
</script>
</head>
<body>
    <p onmouseup="divSize();">
        START
    </p>
    <div id="expand">
        TEXT GOES IN DIV HERE
    </div>
</body>
</html>
if you uncomment out the alert you will see it working ok.
thx in advance,
regards Seanneo