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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Issue (swapping image)

    Hello. I am having a bit of a difficult time here with this javascript I have. It works perfectly for what I want it to do, which is switch the big image with the thumbnails, but I need the big image to change links on switch, so when you click on the big image it takes you to the full size of the preview. Here is the site I am working on:

    http://www.badmotor.com/brent

    If you look to the right, you will see a featured wallpaper section where it offers a big image (the preview image) and below it, 5 thumbnails. Those thumbnails work to switch them out with the big image, which is perfect. The problem is when they switch, the link of the preview image stays the same, therefore not linking them to the correct full size image. Here is the code:

    Code:
    			<div id="wallpapers">
    			<center><a href="http://img14.imageshack.us/img14/9200/tiwall.jpg" name="wallpaper_url"><img src="./images/FeaturedWALL.png" name="img13" border="0" alt="Featured Wallpaper"></a></center>
    			<br>
    			<div class="thumb"><a href="#" onClick="javascript:wallpaper_url.href='www.mynewsite.com';"><img src="./images/Wallthumb1.png" name="img18" border="0" alt="#2" onClick="javascript:img13.src='./images/FeaturedWALL.png';return false;"></a></div><div class="thumb"><a href="#" onClick="javascript:wallpaper_url.href='www.mynewsite.com';"><img src="./images/Wallthumb2.png" name="img19" border="0" alt="#2" onClick="javascript:img13.src='./walls/2.png';return false;"></a></div><div class="thumb"><a href="#" onClick="javascript:wallpaper_url.href='www.mynewsite.com';"><img src="./images/Wallthumb3.png" name="img16" border="0" alt="#2" onClick="javascript:img13.src='./walls/5.png';return false;"></a></div><div class="thumb"><a href="#" onClick="javascript:wallpaper_url.href='www.mynewsite.com';"><img src="./images/Wallthumb4.png" name="img17" border="0" alt="#2" onClick="javascript:img13.src='./walls/3.png';return false;"></a></div><div class="thumb2"><a href="#" onClick="javascript:wallpaper_url.href='www.mynewsite.com';"><img src="./images/Wallthumb5.png" name="img18" border="0" alt="#2" onClick="javascript:img13.src='./walls/4.png';return false;"></a></div>
    
    			</div>
    Any help would be appreciated. Thanks!

  • #2
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would suggest replacing the 'name' attribute in your large images' anchor tag with an 'id' attribute. 'name' is used for constructing links to a specific part of a page - 'id' is used by the DOM to uniquely identify a specific element.

  • #3
    WA
    WA is offline
    Administrator
    Join Date
    Mar 2002
    Posts
    2,596
    Thanks
    2
    Thanked 19 Times in 18 Posts
    Java is very different from JavaScript. I've moved this thread to the later forum category.
    - George
    - JavaScript Kit- JavaScript tutorials and 400+ scripts!
    - JavaScript Reference- JavaScript reference you can relate to.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,588
    Thanks
    80
    Thanked 4,497 Times in 4,461 Posts
    WA: How do you want/prefer that people report posts in wrong forum to you? Or would you rather not get inundated?


  •  

    Posting Permissions

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