[RESOLVED] (Javascript) "Disable" a link/image when at the end of gallery...
ok, im using the below code...(Javascript)
for a gallery.... there are 50+ pics....
Code:
var photos=new Array()
var photoslink=new Array()
var which=0
photos[0]="gallery/b001.jpg"
photos[1]="gallery/b002.jpg"
photos[2]="gallery/b003.jpg"
photos[3]="gallery/b004.jpg"
photos[4]="gallery/b005.jpg"
photos[5]="gallery/b006.jpg"
//etc..etc...
function keeptrack(){
window.status="Image "+(which+1)+" of "+photos.length
}
function backward(){
if (which>0){
which--
document.images.photoslider.src=photos[which]
keeptrack()
}
}
function forward(){
if (which<photos.length-1){
which++
document.images.photoslider.src=photos[which]
keeptrack()
}
}
function transport(){
window.location=photoslink[which]
}
im using this in the page to "include" it...
Code:
<script type="text/javascript" src="slideshow.js">
</script>
and this is how im using it
Code:
<td width="50%" height="21">
<p align="left"><a href="#" onClick="backward();return false" onmouseover="keeptrack();return true" onmouseout="window.status='';" HIDEFOCUS><img src="gallery/previous.jpg" border="0" alt="Previous"></img></a>
</td>
<td width="50%" height="21">
<p align="right"><a href="#" onClick="forward();return false" onmouseover="keeptrack();return true" onmouseout="window.status='';" HIDEFOCUS><img src="gallery/next.jpg" border="0" alt="Next"></img></a>
</td>
ok.. so is there a way.. to remove, or change the "Next" / "Previous" images when u reach the end or beginning of the gallery pics?? so that whn u get to the last image.. the "Next" graphic disappears? (same as when u get to the begining?)
hope I explaained it well enough...
Thanks!!!
Re: (Javascript) "Disable" a link/image when at the end of gallery...
ok.. after about 200 tries.. I got it!!
still learning JS.. ;)
changed the main html doc to "write" the images in like its doing for the gallery.. then tested for 0 or photo.length!
well... posted for others....
Code:
function backward()
{
if (which>0)
{
which--
document.images.photoslider.src=photos[which]
keeptrack()
if (which==0){
document.images.next.src=navpic[1]
document.images.previous.src=navpic[2]
}
else
{
document.images.previous.src=navpic[0]
document.images.next.src=navpic[1]
}
}
}
function forward()
{
if (which<photos.length-1)
{
which++
document.images.photoslider.src=photos[which]
keeptrack()
if (which==photos.length-1){
document.images.next.src=navpic[2]
document.images.previous.src=navpic[0]
}
else {
document.images.previous.src=navpic[0]
document.images.next.src=navpic[1]
}
}
}