www.webdeveloper.com
Results 1 to 2 of 2

Thread: Random-timed image changer with the possibility of changing them manually

  1. #1
    Join Date
    Sep 2012
    Posts
    9

    Random-timed image changer with the possibility of changing them manually

    Hi,

    this is my first post here. Hope I'll get some help here.
    I need someone to look at my code and tell me where I'm wrong. I just started learning JavaScript and I need someone to tell me how to do this (I did it, but it's bugged).

    I have the site code where I've used the given images for an automatic slideshow. I managed to make a script which generates a random number between 3000 and 8000, but generates only whole thousands (3000, 4000, 5000, 6000, 7000 and 8000). These numbers represent the miliseconds for the function I use, which is setTimeout(). I then use the randomly generated time as a parameter in the setTimeout() function, which, in a given random time, calls the rotate() function which switches between the two images (does the image change).
    Now, my boss told me this is a nicely done thing, except that he couldn't make this to work on his regular website (I think we concluded there was a problem with image names later: his images didn't change at all). Nevertheless, he told me he'll try to fix the implementation, because he saw my code worked on my laptop and didn't on his PC, and to try to make the images change not only by themselves with a random timer, but also when a user clicks on the current image.
    I tried doing this by inserting the onclick attribute in the <a> tag, which did the thing he wanted, but the thing is it doesn't work properly: the image changes, but sometimes one of the images appears for too short, which is like it is being skipped. If I try clicking some more, the images start changing faster and faster, until it's unbearable.

    My guess is that something must be wrong with the random time generator, a problem which occurs whenever I click on the image (call the rotate() function for changing the images).
    What do you suggest?

    Thanks.

  2. #2
    Join Date
    Sep 2012
    Posts
    9
    You can download the code from here: http://www.mediafire.com/?9wnb9gv97cgat79

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles