Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
Like Tree1Likes

Thread: Image rotator problems

  1. #1
    Member
    Join Date
    Oct 2011
    Posts
    61
    Member #
    29656

    Image rotator problems

    I am using an image rotator. It is not working properly and I don't know why.

    I have used this for image placement in the content:

    <p class="one"><img src="assets/image/746.jpg" width="200" height="200" alt="Main Image" id="rotator" /></p>

    Here is the java I'm using:

    <script type="text/javascript">
    (function() {
    var rotator = document.getElementById('rotator'); // change to match image ID
    var imageDir = 'assets/image/'; // change to match images folder
    var delayInSeconds = 5; // set number of seconds delay
    // list image names
    var images = ['661', '3MISTIT.jpg', '574.jpg'];

    // don't change below this line
    var num = 0;
    var changeImage = function() {
    var len = images.length;
    rotator.src = imageDir + images[num++];
    if (num == len) {
    num = 0;
    }
    };
    setInterval(changeImage, delayInSeconds * 1000);
    })();
    </script>


    Not sure what I'm doing wrong. I get the original image when you first turn on the page. After that you only get the 3rd and 4th image. I don't have it live yet still trying to test.

    Please help. Trying to add something dynamic to my index.

  2.  

  3. #2
    Member
    Join Date
    Oct 2011
    Posts
    61
    Member #
    29656
    Almost forgot the class on the p tag is only for the bottom border.

  4. #3
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    You'll need to add the first image to the rotator (it's not part of the array) and you'll need to set the second one to 661.jpg. You need the file extension, or else there's no way for a browser or anything/anyone else to know that it's an image.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  5. #4
    Member
    Join Date
    Oct 2011
    Posts
    61
    Member #
    29656
    Thank you for your help. I didn't see the simple thing. I was looking for something difficult.

    New question on the same code. How can I make the images link to other pages on the site?

  6. #5
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    You'd have to surround the image tag with an anchor link : <a href="#" id="rotating-link">your image</a>

    Then you'd create a second array with the links in it (probably right underneath your images array) and add a line changing the href attribute of the rotating-link.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  7. #6
    Member
    Join Date
    Oct 2011
    Posts
    61
    Member #
    29656
    Sorry for the delay in getting back to this. I just got to being ready to add this now. How do I write this array? I tried to used the same array as the image array. It is not working. I know I just need to change a few things to make it work I just can't figure out what. I have tried a few different things.

  8. #7
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    Upload your page somewhere so we can see it, dude. It's hard to say what's going on without seeing it.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  9. #8
    Member
    Join Date
    Oct 2011
    Posts
    61
    Member #
    29656
    I uploaded it.
    Rotator Page

  10. #9
    Member
    Join Date
    Oct 2011
    Posts
    61
    Member #
    29656
    I got the rotator for the images to work great but the link is all the same page. I am not sure what to change on the array.

  11. #10
    Member
    Join Date
    Oct 2011
    Posts
    61
    Member #
    29656
    I just tried to and a file folder to my assets folder with files for to link to and the changed the path it didn't work either. So frustrated.


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:37 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com