SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict Jonny's Avatar
    Join Date
    Mar 2003
    Location
    Norwich, UK
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Having trouble with 'slideshow' script

    I'm trying to adapt a javascript 'slideshow' feature from code I found elsewhere - you can see how far I've got here:

    http://ubtemp.110mb.com/

    In the right-hand column you'll see a rotating image. What should also happen is this:

    1. The caption underneath should be visible (display: block) at the same time as the relevant image is showing, then disappear (display: none) when it is not
    2. The class of the navigational elements below should change when the relevant image shows

    I'm just working on point 1. at the moment. What's happening is the first caption shows, then disappears as it should; however none of the other captions then take its place.

    Any ideas?

    Edit: It's slides.js that I'm editing

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jonny View Post
    I'm trying to adapt a javascript 'slideshow' feature from code I found elsewhere - you can see how far I've got here:

    http://ubtemp.110mb.com/
    Have you tried reading the error console?
    You have a redefined variable:
    Code:
    var sslink = imagename.replace(".png", "");
    var sslink = sslink.replace("images/", "");
    Tab-indentation is a crime against humanity.

  3. #3
    SitePoint Addict Jonny's Avatar
    Join Date
    Mar 2003
    Location
    Norwich, UK
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't really 'get' javascript - could you just explain to me what that means?

    Thanks.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Variables are normally only defined at or before their first use. It's a bad thing when they are defined for a second time because it indicates poorly written code and raises questions like, if one of the defined variables is from some code that was added in later, that is going to affect the other variable at some later stage.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Addict Jonny's Avatar
    Join Date
    Mar 2003
    Location
    Norwich, UK
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks - for the time being I've removed the 'sslink' stuff I'll come to that later. using Firebug, I get this error:

    Code:
    articleid is not defined
    rotateImage("rImage")slides.js (line 65)
    init()slides.js (line 81)
    onload(load )urbane (line 1)
    [Break on this error] document.getElementById('article'+articleid).style.display='block';
    What does this mean?

  6. #6
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jonny View Post
    Thanks - for the time being I've removed the 'sslink' stuff I'll come to that later. using Firebug, I get this error:

    Code:
    articleid is not defined
    rotateImage("rImage")slides.js (line 65)
    init()slides.js (line 81)
    onload(load )urbane (line 1)
    [Break on this error] document.getElementById('article'+articleid).style.display='block';
    What does this mean?
    On the currently hosted version, ssLink is undefined. Can't properly comment on your current error until you update the code.
    Tab-indentation is a crime against humanity.

  7. #7
    SitePoint Addict Jonny's Avatar
    Join Date
    Mar 2003
    Location
    Norwich, UK
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Apologies - try now.

  8. #8
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jonny View Post
    Apologies - try now.
    On this line it's complaining because articleid isn't defined anywhere.
    Code:
    document.getElementById('article'+articleid).style.display='block';
    It look as though articleid ought to be replaced by the existing variable
    ImageNum, which may need to be written as (ImageNum+1).
    Tab-indentation is a crime against humanity.


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
  •