SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with code - DW template, Javascript & CSS

    Hi,
    I am having trouble getting my images to swap onclick on my gallery page. I am sure it must have something to do with the paths as I am using a DW template - /templates/rates.dwt and a css file - gallery.css and a javascript file gallery.jsp.
    I have gone over it a million times and I would love if someone else could look at it.
    The page I'm referring to is http://www.loudwhisperhouseboat.com.au/gallery.html
    Any help would be appreciated.

  2. #2
    SitePoint Member GreboGuru's Avatar
    Join Date
    Jun 2006
    Location
    Wensleydale, UK
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    By the looks of it the code to swap the image is dependent an element with an id of 'caption'. Your page doesn't contain a 'caption' element?

    Hope this helps

    Scott

    Code:
    function swapPhoto(photoSRC,theCaption,theCredit) 
    {
    	if (document.getElementById("caption")) 
    	{
    		var theImage = document.getElementById("mainPhoto");
    		var displayedCaption = document.getElementById("caption");
    		var displayedCredit = document.getElementById("credit");
    		var imgFolder = "assets/";
    		displayedCaption.firstChild.nodeValue = theCaption;
    		displayedCredit.firstChild.nodeValue = theCredit;
    		theImage.setAttribute("src", imgFolder+photoSRC);
     	}
    }

  3. #3
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face You were right!! Thanks

    Thanks Scott,
    I did have a caption in the code and then removed it - soon as I put it back in with the credit it all worked.
    You're a champion!


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
  •