www.webdeveloper.com
Results 1 to 5 of 5

Thread: What am I doing wrong?

  1. #1
    Join Date
    Jul 2010
    Posts
    2

    What am I doing wrong?

    I thought this would work, but I am obviously doing something wrong.
    Any help would be great.


    <!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>Untitled Document</title>

    </head>

    <script type="text/javascript">
    var slides = new Array(3); // the number in brackets defines how many images your gallery has
    var j=0;
    for(var i=1; i<=3; i++){
    slides[i] = new Image();
    slides[i].src = "images/tonaquint_" + i + ".jpg"; }
    function Swap(number){
    document.slide.src = slides[number].src;}
    </script>



    <body>

    <table width="681" height="474" border="1">
    <tr>
    <td><table width="681" height="474" border="1">
    <tr>
    <td colspan="3" align="center"><img name="slide" src="images/tonaquint_one.jpg" width="523" height="392"></td>
    </tr>
    <tr>
    <td><a href="javascript:Swap(1)"><img src="images/thumb_tonaquint_one.jpg" border="0" /></a></td>
    <td><a href="javascript:Swap(2)"><img src="images/thumb_tonaquint_two.jpg" border="0" /></a></td>
    <td><a href="javascript:Swap(3)"><img src="images/thumb_tonaquint_three.jpg" border="0" /></a></td>
    </tr>
    </table> </td>
    </tr>
    </table>

    </body>


    </html>

  2. #2
    Join Date
    Mar 2010
    Posts
    2,803
    Some Basic Debugging 101 should help you find the bug the in your code.

    hint: you're not preloading your images correctly.

    Your code works ok when I test it with my own test pics.
    Last edited by tirna; 07-24-2010 at 12:09 AM.

  3. #3
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    1. var j = 0; - what was it for?
    2. what are the names of the images:
    tonaquint_one.jpg,tonaquint_two.jpg,tonaquint_three.jpg
    or
    tonaquint_1.jpg,tonaquint_2.jpg,tonaquint_3.jpg,tonaquint_4.jpg
    ?
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  4. #4
    Join Date
    Jul 2010
    Posts
    2
    Thanks for the help tirna and Padonak. Im a moron with this stuff. But I have it working now with your info. Had to change my files to tonaquint_1 instead of tonaquint_one of course.

  5. #5
    Join Date
    Mar 2010
    Posts
    2,803
    it's an easy mistake to make - glad you sorted it out in the end

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles