Results 1 to 5 of 5

Thread: Displaying Photo Number

  1. #1
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Displaying Photo Number

    1) Script Title: DHTML Slide Show Script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...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 ?

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <!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>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default what about

    the way it starts with zero.Can it be changed to start with 1 ?

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    function shownumber(){
     document.getElementById('number').innerHTML=which+1;
    }
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •