Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with counting in reverse order.

    Hello. I am working snippet of js that controls a photo galleries count is 1 of 8.

    Thing is I can't get this to count backwards. I can make it count from -8 to -1, but that's not what I am trying to do.

    I am trying it to start on image 8 of 8 in the gallery and as I progress through the number subtracts 1 or just counts in reverse until I arrive at image 1 of 8.

    Is there a clear way to achieve this with out breaking this code?

    Code:
    			 if(this.mode == 'imageGallery'){ 
    			 	this.count.appendText((this.currentIndex+length-9)+' of '+this.currentGallery.length); 
    			 }

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Do you by chance could provide a link.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #3
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't have the code online. Sry.

  • #4
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    This will get you started
    Code:
    function count_down(arr){
         for(i=arr.lenght;i>0;i--){
         }
    }
    I'm not positive about what you want to do, so I couldn't add more, but this loop will count down for you.


  •  

    Posting Permissions

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