Results 1 to 3 of 3

Thread: swap more images with onClick

  1. #1
    Join Date
    Oct 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy swap more images with onClick

    Hi, can anybody tell me how to complete this code (taken in part from (DF) all I need now is to have at least 10 images that act as buttons so that when you 'onClick' the image will swap with another image.

    I have attached my code so you can see. at the moment, the problem is, the second button when clicked, swaps with the 1st image

    Hope this makes sense

    Any help would be much appreciated


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

    <html>

    <head>
    <title></title>
    <script language="JavaScript" src="CAL_JS.js"></script>

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

    <script type="text/javascript">


    function Swap(obj){
    obj.src=(Swap.swaped=!Swap.swaped)? 'images/cal_jan_over.gif' : 'images/cal_jan.gif';
    }
    {
    obj.src=(Swap.swaped=!Swap.swaped)? 'images/cal_feb_over.gif' : 'images/feb_jan.gif';
    }
    </script>
    </script>
    </head>

    <body>

    <table width="400" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="183"><a href="javascript:;"><img src='images/cal_jan.gif' width=183 height="15" onclick="Swap(this);showhide(JAN)" id="image1" ></a></td>
    <td width="217">&nbsp;</td>
    </tr>
    <tr>
    <td class = archiveBox id="JAN" style="display:none;">
    <span class="articleArchive" >
    <a href="#">blar blar blar blar blar</a></br></br>
    <br />
    <a href="#">blar blar blar blar blar</a><br />
    <a href="#">blar blar blar blar blar</a> </span> </td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td width="183"><a href="javascript:;"><img src='images/cal_feb.gif' width=183 height="15" onclick="Swap(this);showhide(FEB)" id="image2" ></a></td>
    <td width="217">&nbsp;</td>
    </tr>
    <tr>
    <td class = archiveBox id="FEB" style="display:none;">
    <span class="articleArchive" >
    <a href="#">blar blar blar blar blar</a></br></br>
    <br />
    <a href="#">blar blar blar blar blar</a><br />
    <a href="#">blar blar blar blar blar</a> </span> </td>
    <td>&nbsp;</td>
    </tr>
    </table>

    </body>

    </html>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Oct 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    jscheuer1, you're a star. worked a treat. I spent ages trying to find a thread that explained it.

    thanks a mill.

Bookmarks

Posting Permissions

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