SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Zealot moretea's Avatar
    Join Date
    Jun 2004
    Location
    Texas, USA
    Posts
    118
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Question Image replacement in a gallery? Not sure what's wrong

    This seems like such a n00b question in 2007, but... what am I doing wrong? I have thumbnail images marked up like so...
    Code HTML:
    <div id="thumb001">
                            <a class="thumb" title="/img/img01.jpg"><img src="img/img001_thumb.jpg" alt="Img001 thumbnail"  /></a><br />
                            <a class="thumb" title="/img/img01.jpg">Image 001</a>
                            </div>
                            <div id="thumb002">
                            <a class="thumb" title="/img/img02.jpg"><img src="img/img002_thumb.jpg" alt="Img002 thumbnail"  /></a><br />
                            <a class="thumb" title="/img/img02.jpg">Image 002</a>
                            </div>
    .
    .
    .
    I have a div for the full size display of the selected image...
    Code HTML:
    <div id="div_selected">
                    <img id="selected" name="selected" src=""  />
                </div>
    ...And I have JavaScript that returns an alert, but doesn't switch out the image like I thought it would.
    Code JavaScript:
    <script type="text/javascript">
    var findPic = {
        init: function()
        {
            var links = Core.getElementsByClass("thumb");
            for (i=0; i < links.length; i++) 
            {
                links[i].onclick = findPic.clickHandler;
            }
        },
        clickHandler: function() 
        {
            document.selected.src = this.title;
            alert(this.title);
            return false;
        }
     
    }
    Core.start(findPic);
    </script>

  2. #2
    SitePoint Zealot moretea's Avatar
    Join Date
    Jun 2004
    Location
    Texas, USA
    Posts
    118
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    D'oh!

    Stupid mistake on my part--I had the wrong path to the images. Seems to work in both IE6 and Firefox 2 now!


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
  •