|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Okay webmasters, please put your wizard hats on and work your magic.
I have a great little slide show that I am working on. I just about have it done, but I have a problem that is driving me nuts!!! The problem is my "back" button. Once the back button hits the first image and the user clicks back again, a javascript error occurs (it states: That my variable is not defined). I know that it is defined otherwise the back button would not work at all. The "next" button does not have this problem it will loop continously. I have been researching others slideshows and a lot of them use seperate html pages or have an alert appear when the user tries to go past the first image. Here's the code: Note** imageDB is the array for all the images. function next() { if (boardNum < imageDB.length - 1) boardNum++; else boardNum = 0; document.selections.cached.selectedIndex = boardNum document.thumbnail1.src = imageDB[boardNum].src boardSpeed=6000; } function back() { if (boardNum < imageDB.length - 1) boardNum--; else boardNum = 0; document.selections.cached.selectedIndex = boardNum document.thumbnail1.src = imageDB[boardNum].src boardSpeed=6000; } // This is the function for rotation of images, call for this in the body<tag> onload function rotateBoard() { if (boardNum < imageDB.length - 1) boardNum++; else boardNum = 0; document.selections.cached.selectedIndex = boardNum document.thumbnail1.src = imageDB[boardNum].src setTimeout('rotateBoard()', boardSpeed); } My goal is for the back button to jump back on image 1 and go to the last image and then continue to count down from there. I have tried using an if statement, it removed the error but the back button would only go to the first image and that was it. Also, would you happen to know of a good reliable tool for compiling javascript in. A watch/debugger utility, where I can run a script and watch how it plays out with the variables and functions. I thank you in advance for any help... Cherie |
|
#2
|
|||
|
|||
|
Try using the onUnload object for when leaving a document. Make it write boardnum to a variable called back(or something similar).
Have function back call on this variable instead. This method will only go back once unless you can figure out some way to use an array to create a history. Sorry I can't give you more details but I'm a beginner still. I hope I've been of some help. ------------------ If our time is up, what is down? |
|
#3
|
|||
|
|||
|
Thank you for your response.
I am using an array to control the images that swap. It is imageDB. Then boardNum (which calls to the same array imageDB) is used to control the back and next buttons in a function. I have researched the web looking for slideshows that swap images(not pages) in the same page and have next and back buttons, I noticed that none of them let you go back past the first image. I know I am not alone in this quest... |
|
#4
|
|||
|
|||
|
The if statment in your back function that looks like this:
if (boardNum < imageDB.length - 1) boardNum--; else boardNum = 0; Should probably look like this if (boardNum > 0) boardNum--; else boardNum = imageDB.length-1; The first version would allow the boardNum to become negative, causing an error, the second one will return the boardNum index to the end of the array. |
|
#5
|
|||
|
|||
|
tkessler,
Hat's off to you!!! Thank you so much! I hope someday,somehow I will be able to return the favor. Thank's again, Cherie |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Baffled |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|