Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with hide/show div

    this is what im trying to do: http://www.linkstraffic.net/programm...d/movebox.html

    using this code: http://www.linkstraffic.net/programm...nd/movediv.php

    heres my code. can someone fix it?

    html:

    [CODE]

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Chris MacDonald - Javascript Assignment 2</title>

    <link href="styles/styles.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="java.js"></script>

    <div id="header">
    <div id="logo"><img src="images/beat.png" /></div>
    </div>

    <ul id="nav">
    <li><a href="#">Home</a></li>
    <li><a href="http://beatthreads.bigcartel.com/category/tees">Shirts</a></li>
    <li><a href="#">About Us</a></li>
    </ul>

    </head>

    <body>

    <div id="content">

    <a href="#" onclick="interv=setInterval('ShowBox()',3);return false;">Upcoming Designs</a>

    <div id="coverlogin">

    <div id="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus tristique cursus dui, a venenatis diam consectetur fermentum. Nulla facilisi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent aliquam ornare nunc non semper. Morbi blandit lectus non elit ultricies ultricies. Fusce mattis purus et eros ultrices et facilisis nulla consequat. Vestibulum tellus libero, tempor vel tincidunt nec, consectetur non ante. Donec sed malesuada felis. Mauris lorem lorem, ornare a rutrum quis, rutrum in mauris. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.

    <br/>

    <p align="left"><a href="#" onClick="interv=setInterval('HideBox()',3);return false;">X</a></p>
    </div>

    </div>
    </div>


    <div id="footer">
    <div id="footertext">Beat Threads - 2010</div>
    </div>





    </body>
    </html>
    [CODE]

    javascript:

    // JavaScript Document

    var hh=0;
    var interv;

    //we show the box by setting the visibility of the element and incrementing the height smoothly
    function ShowBox()
    {

    //Depending on the amount of text, set the maximum height here in pixels
    if(hh==40)
    {
    clearInterval(interv);
    return;
    }

    obj = document.getElementById("coverlogin");
    obj.style.visibility = 'visible';
    hh+=2;
    obj.style.height = hh + 'px';
    }

    function HideBox()
    {
    obj = document.getElementById("coverlogin");

    if(hh==2)
    {
    obj.style.visibility = 'hidden';
    obj.style.height = '0.1em';
    clearInterval(interv);
    return;
    }
    hh-=2;
    obj.style.height = hh + 'px';
    }

    [CODE]

    Can someone fix this for me?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,210
    Thanks
    75
    Thanked 4,343 Times in 4,309 Posts
    I give up, what's the difference between the two?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i ended up figuring it out. i just couldnt get the hide to fire. thanks for giving it a look anyway.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •