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 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Switching Image in single Div

    Hello,

    I've been struggling to find a decent code example of how to create a switching image in a div when you hover over an anchor.

    What I'm trying to create is a layout where I can have multiple anchors that link to multiple images that are shown in a single div or frame.

    Any suggestions would be greatly appreciated.

  • #2
    Regular Coder
    Join Date
    Oct 2010
    Location
    San Antonio Tx
    Posts
    251
    Thanks
    12
    Thanked 11 Times in 11 Posts
    thats very hard to understand, do you know a site with an example of something you want your layout to look like? maybe we could better understand how to help you

  • #3
    New Coder
    Join Date
    Nov 2010
    Posts
    43
    Thanks
    4
    Thanked 2 Times in 2 Posts
    I'd suggest trying to use a Javascript image gallery.

    Check out:

    http://valums.com/javascript-image-galleries/

    You can probably adapt the second one down to the functionality you're describing.

    All of the above is a suggestion based on what I can ascertain from your post, if it's not helpful, oops!

  • #4
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Here's an example that was created by someone but it is using tables... Basically a sliced photoshop image so the code is a mess but it does what I'd like to do only with better compliant code. Notice how when you hover over one of the yellow arrows it switches the image in the box on the layout. I'd lik to do this only with using html and css. Java script would be ok too I suppose but I don't know hardly anything in java.

    http://hughgriffithvt.com/fairhill/main_level.html

    Here's another example using a javascript lighbox that is something I would not like to use but has better more compliant code.

    http://hughgriffithvt.com/emeraldglen_vt/index.html

    Thanks,

  • #5
    Banned
    Join Date
    Jul 2010
    Posts
    66
    Thanks
    0
    Thanked 1 Time in 1 Post
    Hi,
    you can try out with j query to switch the images the logic is

    when you click the image

    link is below
    http://www.queness.com/resources/htm...slideshow.html

  • #6
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post
    <code>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>image test</title>
    <script type="text/javascript">
    //--Preload Images
    var image1=new Image()
    image1.src="img1.jpg"
    var image2=new Image()
    image2.src="img2.jpg"
    var image3=new Image()
    image3.src="img3.jpg"

    function changeImage(imageId, new_Image){
    document.getElementById(imageId).src=new_Image
    }
    </script>
    </head>
    <body>
    <div id="anchors"></div>
    <ul>
    <li><a id="anchor1" href="#" onmouseover="changeImage('imgholder','img1.jpg')">Anchor 1</a></li>
    <li><a id="anchor1" href="#" onmouseover="changeImage('imgholder','img2.jpg')">Anchor 2</a></li>
    <li><a id="anchor1" href="#" onmouseover="changeImage('imgholder','img3.jpg')">Anchor 3</a></ul></li>
    <div id="image_display"><img id="imgholder" src="startimg.jpg" /></div>
    </body>
    </html>

    </code>

  • Users who have thanked rpotech for this post:

    r3drum (11-18-2010)

  • #7
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,335
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Not sure if they would have what your looking for, but I use dynamicdrive quite a bit. They have tons of code snippets. Anything from floating snowflakes to very advanced image viewers.

  • #8
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello r3drum,
    It doesn't have to be js ... It can be just plain ol' CSS too. Have a look at this example.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #9
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,903
    Thanks
    15
    Thanked 226 Times in 226 Posts
    How about something like this?

    http://ronbeau.50webs.com/Latest/

  • #10
    Banned
    Join Date
    Aug 2010
    Location
    everywhere
    Posts
    63
    Thanks
    2
    Thanked 3 Times in 3 Posts
    You can create you div then place in an image:
    <div><img src="http://mysite.com/image/placeholder.jpg" id="switchingimage"></div>

    <a href="http://mysite.com/images/image1.jpg" onmousevover="RevealImg(this.href)">
    <a href="http://mysite.com/images/image1.jpg" onmousevover="RevealImg(this.href)">
    <a href="http://mysite.com/images/image1.jpg" onmousevover="RevealImg(this.href)">

    Create a javascript function:

    function RevealIm(url){
    if(url!=''){
    document.getElementById("switchingimage").src=url;
    }
    }


  •  

    Posting Permissions

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