PDA

View Full Version : Displaying Photo Number



Herisson
07-24-2011, 10:08 AM
1) Script Title: DHTML Slide Show Script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex14/dhtmlslide.htm

3) Describe problem: I am using this script to navigate a catalogue of pages in image format . How can I get it to display the photo number displayed on the web page somewhere ?

vwphillips
07-24-2011, 03:37 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>
<script type="text/javascript">

/***********************************************
* DHTML slideshow script- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice must stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var photos=new Array()
var photoslink=new Array()
var which=0

//define images. You can have as many as you want:
photos[0]="http://www.dynamicdrive.com/dynamicindex14/photo1.jpg"
photos[1]="http://www.dynamicdrive.com/dynamicindex14/photo2.jpg"
photos[2]="http://www.dynamicdrive.com/dynamicindex14/photo3.jpg"

//Specify whether images should be linked or not (1=linked)
var linkornot=0

//Set corresponding URLs for above images. Define ONLY if variable linkornot equals "1"
photoslink[0]=""
photoslink[1]=""
photoslink[2]=""

//do NOT edit pass this line

var preloadedimages=new Array()
for (i=0;i<photos.length;i++){
preloadedimages[i]=new Image()
preloadedimages[i].src=photos[i]
}


function applyeffect(){
if (document.all && photoslider.filters){
photoslider.filters.revealTrans.Transition=Math.floor(Math.random()*23)
photoslider.filters.revealTrans.stop()
photoslider.filters.revealTrans.apply()
}
}



function playeffect(){
if (document.all && photoslider.filters)
photoslider.filters.revealTrans.play()
}

function keeptrack(){
window.status="Image "+(which+1)+" of "+photos.length
}


function backward(){
if (which>0){
which--
applyeffect()
document.images.photoslider.src=photos[which]
shownumber();
playeffect()
keeptrack()
}
}

function forward(){
if (which<photos.length-1){
which++
applyeffect()
document.images.photoslider.src=photos[which]
shownumber();
playeffect()
keeptrack()
}
}

function transport(){
window.location=photoslink[which]
}

function shownumber(){
document.getElementById('number').innerHTML=which;
}
</script>
</head>

<body>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" colspan="3" height="22"><center>
<script>
if (linkornot==1)
document.write('<a href="javascript:transport()">')
document.write('<img src="'+photos[0]+'" name="photoslider" style="filter:revealTrans(duration=2,transition=23)" border=0>')
if (linkornot==1)
document.write('</a>')
</script>
</center></td>
</tr>
<tr>
<td width="33%" height="21"><p align="left"><a href="#" onClick="backward();return false">Previous Slide</a></td>
<td id="number" width="33%" height="21" style="text-Align:center;" >0</td>
<td width="33%" height="21"><p align="right"><a href="#" onClick="forward();return false">Next Slide</a></td>
</tr>
</table>

<p align="center"><font face="Arial" size="-2">Free DHTML scripts provided by<br>
<a href="http://dynamicdrive.com">Dynamic Drive</a></font></p>

</body>

</html>

ajfmrf
07-25-2011, 02:17 AM
the way it starts with zero.Can it be changed to start with 1 ?

djr33
07-25-2011, 03:17 AM
Numerical array keys/indexes always start with 0. You can skip 0 and use 1, but this will leave a gap and might cause problems depending on how you use the array later. It's best to start with 0.

vwphillips
07-25-2011, 08:52 AM
function shownumber(){
document.getElementById('number').innerHTML=which+1;
}