Javascript If... else homework

Discussion in 'OT Technology' started by tour4fun, Oct 5, 2007.

  1. tour4fun

    tour4fun Faster ... OT Supporter

    Joined:
    Jan 19, 2007
    Messages:
    136
    Likes Received:
    0
    Location:
    Sunny
    Please help me with my homework :). I need to use the else if statement, but I can't get my banners to change?

    <html>
    <head>
    <title>Banners</title>
    <script type="text/javascript">
    <!-- Hide from incompatible browsers

    var curBanner="adImage1";
    var begin;
    function changeBanner() {
    if (curBanner == "adImage1")
    {document.images[0].src="adImage1.gif";
    curBanner="adImage2";
    }
    else if (curBanner == "adImage2.gif")
    {document.images[0].src="adImage2.gif";
    curBanner="adImage3.gif";
    }
    else if (curBanner == "adImage3.gif")
    {document.images[0].src="adImage3.gif";
    curBanner="adImage4.gif";
    }
    else if (curBanner == "adImage4.gif")
    {document.images[0].src="adImage4.gif";
    curBanner="adImage5.gif";
    }
    else if (curBanner == "adImage5.gif")
    {document.images[0].src="adImage5.gif";
    curBanner="adImage1.gif";
    }
    }


    // Stop hiding from incompatible browsers -->
    </script>

    </head>

    <body onload="var begin=setInterval('changeBanner()',5000);">
    <p><img src="adImage1.gif" alt="Image 1" /></p>

    </body>
    </html>

    :x: :wavey:
     
  2. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
  3. Cthalupa

    Cthalupa New Member

    Joined:
    May 5, 2006
    Messages:
    46,930
    Likes Received:
    0
    Location:
    Dallas, Texas
    He's asking for help, not for it to be done for him.
     
  4. tour4fun

    tour4fun Faster ... OT Supporter

    Joined:
    Jan 19, 2007
    Messages:
    136
    Likes Received:
    0
    Location:
    Sunny
    :wtc: :wtc: :wtc:
     
  5. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    You're being inconsistent with including file extensions in your filenames. That's all I'm going to say.
     
  6. crontab

    crontab (uid = 0)

    Joined:
    Nov 14, 2000
    Messages:
    23,443
    Likes Received:
    12
  7. Sexual Vanilla

    Sexual Vanilla New Member

    Joined:
    May 23, 2005
    Messages:
    6,305
    Likes Received:
    0
    Location:
    South Carolina
    :bigthumb:
     

Share This Page