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 5 of 5
  1. #1
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts

    slideshow to read images from directory, not array

    is there a way to get a slideshow to read every image from a directory (folder)... and avoid me having to type 65 image names into an array?

    if there is no way, how can i just copy all the files and say "paste names" into a .txt file (like how irc servers have a downloadable .txt of every file they have)
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Server side scripting is the answer
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is there anything that would preclude you from naming the images sequentially, like:

    image1.gif
    image2.gif
    image3.gif
    etc.

    If not, then just reference them like this:

    Code:
    <script>
    <!--
    
    var imgCnt = 66;
    
    function Imgs(){
    
    var oImg = new Image();
    for (var i=1;i<imgCnt;i++){
    oImg.src = "images/image" + i + ".gif";
    alert(oImg.src);
    }
    }
    window.onload = Imgs;
    
    //-->
    </script>
    That's just an example though. But it depends on how you want to use them, like, what does slideshow mean to you? Are the images going to be preloaded, will the slideshow advance automatically, using setInterval(), or will it be interactive, like when someone clicks on a button, etc.?



    -james
    Last edited by jamescover; 08-11-2004 at 02:25 AM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #4
    JPM
    JPM is offline
    Regular Coder
    Join Date
    Mar 2004
    Location
    Norway
    Posts
    204
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think that ^ would be the best way to do it. Though I think a for loop will display all the images in like half a second.

    Code:
    var x = 1
    
    function imgs() 
    {
      myImg.src = "images/image" +x+ ".gif"
      x++;
      if(x==60) clearInterval(intV)
    }
    
    var intV = setInterval("imgs()",3000);

    If you want to go server side you might want to look at this
    (asp)
    Last edited by JPM; 08-11-2004 at 02:09 PM.
    <JPM />

  • #5
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    sweet, lemme see what i can drum up with that asp script
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)


  •  

    Posting Permissions

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