PDA

View Full Version : Simple JavaScript slideshow, first image error



bugmenot
02 Dec 2009, 01:05 PM
This is a simple problem, so I won't waste any time writing some huse paragraph about what's wrong. A simple website I've made for my class has a problem with its slideshow: the 'next' button does nothing on the first click. On the second it goes to the next image and everything is fine from there. But it's pretty annoying. Can anyone help me out?

page source: http://pastebin.com/m3c40cbaa
(pastebin sort of botched the formatting. Just ignore it.)

dmcleary
03 Dec 2009, 11:21 AM
HI bugmenot,

I'm not sure if this is the solution but it's certainly something that might held.

num is set to 1 when the page loads.

Then, when you call the function you are immediately incrementing 1, so the slide show starts at 2.

If you set num to 0 in the initialisation the first image will show.

I'm not sure how that relates to the issue with clicking twice but I trust it helps.

Regards,


David