![]() |
|
|
#1
|
|||
|
|||
|
Simple image viewer
I want to make very simple page where I have two buttons(previous and next) and when I click on them the pictures change(forward and backward).
Shouldn't it be something like this: <head> function next() { if (document.slideform.slide[current+1]) { document.images.show.src = document.changer.slide[current+1].value; document.changer.slide.selectedIndex = ++current; } function previous() { if (current-1 >= 0) { document.images.show.src = document.slideform.slide[current-1].value; document.changer.slide.selectedIndex = --current; </head> <body> <form name=changer> <tr> <td align=center bgcolor="#C0C0C0"> <input type=button onClick="previous();" value="<<" title="Previous"> <input type=button onClick="next();" value=">>" title="Next"> </td> </tr> </body> Perhaps somebody has allready finished script to do this? |
|
#2
|
||||
|
||||
|
If you're using asp, I have code I've written that does exactly that, but it's timed so it works like a slide show as well, with a pause button if you want to stop on a given image.
|
|
#3
|
|||
|
|||
|
Thanks, but it has to be in non-server script-javascript.
|
|
#4
|
||||
|
||||
|
Have you searched places like javascript.com or other tech sites for a script. I'm sure there must be dozens of them out there. I thought about using javascript, but I did not want to load large images in the background.
|
|
#5
|
|||
|
|||
|
$img = new setarray(3);
$img[1] = "pic1a.jpg"; $img[2] = "pic2a.jpg"; $img[3] = "pic3a.jpg"; function setarray(n){ this.length = n; for (var i = 1; i <= n; i++); this[i] = 0; return this; } function fwd() { if(ind < 6){ ind = ind + 1 var i2mod = document.getElementById('image'); i2mod.src = $img[ind]; } } function back() { if(ind > 1){ ind = ind - 1 var i2mod = document.getElementById('image'); i2mod.src = $img[ind]; } } make your page buttons, use back() and fwd(), it works; to reset it, make button, have onclick be something like "ind=0;fwd();return true;" questions? see my thread above yours, i still have questions! =b |
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can you use an image as a border option in CSS? | NewComputer | CSS | 6 | Aug 6th 2009 6:28 am |
| Image ads vs text ads - what is better in $ revenue | hans | AdSense | 18 | May 17th 2009 9:42 am |
| Checking source codes of image, audio and video files | onauc | Programming | 0 | Feb 21st 2005 5:34 pm |
| Centering an Image within a Block Element | robert_neville | CSS | 1 | Feb 12th 2005 7:13 pm |
| Setting up a linked image series | Don Key | HTML & Website Design | 4 | Nov 23rd 2004 1:58 pm |