1 Replies - 3793 Views - Last Post: 18 September 2012 - 12:40 PM

#1 boris90  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 62
  • Joined: 15-November 09

Random-timed image changer and changing them manually

Posted 17 September 2012 - 08:56 AM

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?

Download the code here (recommended because of images): http://www.mediafire...9wnb9gv97cgat79


Is This A Good Question/Topic? 0
  • +

Replies To: Random-timed image changer and changing them manually

#2 JMRKER  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 133
  • View blog
  • Posts: 868
  • Joined: 25-October 08

Re: Random-timed image changer and changing them manually

Posted 18 September 2012 - 12:40 PM

I'm disinclined to download 594KB of code.
Do you have a BRIEF example of your problem available?
Something with a simple HTML image layout, JS code for the random change display and a link to the directory where the images are contained?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1