How do I get code to access the images at the URL given?Array Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tpgames
    Contributor
    • Jan 2007
    • 783

    How do I get code to access the images at the URL given?Array Question

    How do I get code to access the images at the URL given?
    I'd like the user to be able to select which theme of images they want to view then the script would randomly pick an image to show.

    Code:
    <!--BEGIN
    // Customising Variables
    
    // Arrays of Images that can be used in the game
    var ImgAry=['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg','9.jpg','10.jpg','11.jpg','12.jpg','13.jpg','14.jpg','15.jpg','16.jpg','17.jpg','18.jpg','19.jpg','20.jpg','21.jpg','22.jpg','23.jpg','24.jpg','25.jpg','26.jpg','27.jpg','28.jpg','29.jpg','30.jpg','32.jpg','33.jpg','34.jpg','35.jpg','36.jpg','37.jpg','38.jpg','39.jpg','40.jpg','41.jpg','42.jpg','43.jpg','44.jpg','45.jpg','46.jpg','47.jpg','48.jpg','49.jpg','50.jpg','51.jpg','52.jpg','53.jpg','54.jpg','55.jpg','56.jpg','57.jpg','58.jpg','59.jpg','60.jpg','61.jpg','62.jpg','63.jpg','64.jpg','65.jpg','66.jpg','67.jpg','68.jpg','69.jpg','70.jpg','71.jpg','72.jpg','73.jpg','74.jpg','75.jpg','76.jpg','77.jpg','78.jpg','79.jpg','80.jpg','81.jpg','82.jpg','83.jpg','84.jpg','85.jpg','86.jpg','87.jpg','88.jpg','89.jpg','90.jpg','91.jpg','92.jpg','93.jpg','94.jpg','95.jpg','96.jpg','97.jpg','98.jpg','99.jpg','100.jpg','101.jpg','102.jpg','103.jpg','104.jpg','105.jpg','106.jpg','107.jpg','108.jpg','109.jpg','110.jpg','111.jpg','112.jpg','113.jpg','114.jpg','115.jpg','116.jpg','117.jpg','118.jpg','119.jpg','120.jpg','121.jpg','122.jpg','123.jpg','124.jpg','125.jpg','126.jpg','127.jpg','128.jpg','129.jpg','130.jpg','131.jpg','132.jpg','133.jpg','134.jpg','135.jpg'];
    var ImgAry2=['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg','9.jpg','10.jpg','11.jpg','12.jpg','13.jpg','14.jpg','15.jpg','16.jpg','17.jpg','18.jpg','19.jpg','20.jpg','21.jpg','22.jpg','23.jpg','24.jpg','25.jpg','26.jpg','27.jpg','28.jpg','29.jpg','30.jpg','32.jpg','33.jpg','34.jpg','35.jpg','36.jpg','37.jpg','38.jpg','39.jpg','40.jpg','41.jpg','42.jpg','43.jpg','44.jpg','45.jpg','46.jpg','47.jpg','48.jpg','49.jpg','50.jpg','51.jpg','52.jpg','53.jpg','54.jpg','55.jpg','56.jpg','57.jpg','58.jpg','59.jpg','60.jpg','61.jpg','62.jpg','63.jpg','64.jpg','65.jpg','66.jpg','67.jpg','68.jpg','69.jpg','70.jpg','71.jpg','72.jpg','73.jpg','74.jpg','75.jpg','76.jpg','77.jpg','78.jpg','79.jpg','80.jpg','81.jpg','82.jpg','83.jpg','84.jpg','85.jpg','86.jpg','87.jpg','88.jpg','89.jpg','90.jpg','91.jpg','92.jpg','93.jpg','94.jpg','95.jpg','96.jpg','97.jpg','98.jpg','99.jpg','100.jpg','101.jpg','102.jpg','103.jpg','104.jpg','105.jpg','106.jpg','107.jpg','108.jpg','109.jpg','110.jpg','111.jpg','112.jpg','113.jpg','114.jpg','115.jpg','116.jpg','117.jpg','118.jpg','119.jpg','120.jpg','121.jpg','122.jpg','123.jpg','124.jpg','125.jpg','126.jpg','127.jpg','128.jpg','129.jpg','130.jpg','131.jpg','132.jpg','133.jpg','134.jpg','135.jpg'];
    var ImgAry3=['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg','9.jpg','10.jpg','11.jpg','12.jpg','13.jpg','14.jpg','15.jpg','16.jpg','17.jpg','18.jpg','19.jpg','20.jpg','21.jpg','22.jpg','23.jpg','24.jpg','25.jpg','26.jpg','27.jpg','28.jpg','29.jpg','30.jpg','32.jpg','33.jpg','34.jpg','35.jpg','36.jpg','37.jpg','38.jpg','39.jpg','40.jpg','41.jpg','42.jpg','43.jpg','44.jpg','45.jpg','46.jpg','47.jpg','48.jpg','49.jpg','50.jpg','51.jpg','52.jpg','53.jpg','54.jpg','55.jpg','56.jpg','57.jpg','58.jpg','59.jpg','60.jpg','61.jpg','62.jpg','63.jpg','64.jpg','65.jpg','66.jpg','67.jpg','68.jpg','69.jpg','70.jpg','71.jpg','72.jpg','73.jpg','74.jpg','75.jpg','76.jpg','77.jpg','78.jpg','79.jpg','80.jpg','81.jpg','82.jpg','83.jpg','84.jpg','85.jpg','86.jpg','87.jpg','88.jpg','89.jpg','90.jpg','91.jpg','92.jpg','93.jpg','94.jpg','95.jpg','96.jpg','97.jpg','98.jpg','99.jpg','100.jpg','101.jpg','102.jpg','103.jpg','104.jpg','105.jpg','106.jpg','107.jpg','108.jpg','109.jpg','110.jpg','111.jpg','112.jpg','113.jpg','114.jpg','115.jpg','116.jpg','117.jpg','118.jpg','119.jpg','120.jpg','121.jpg','122.jpg','123.jpg','124.jpg','125.jpg','126.jpg','127.jpg','128.jpg','129.jpg','130.jpg','131.jpg','132.jpg','133.jpg','134.jpg','135.jpg'];
    var ImgAry4=['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg','9.jpg','10.jpg','11.jpg','12.jpg','13.jpg','14.jpg','15.jpg','16.jpg','17.jpg','18.jpg','19.jpg','20.jpg','21.jpg','22.jpg','23.jpg','24.jpg','25.jpg','26.jpg','27.jpg','28.jpg','29.jpg','30.jpg','32.jpg','33.jpg','34.jpg','35.jpg','36.jpg','37.jpg','38.jpg','39.jpg','40.jpg','41.jpg','42.jpg','43.jpg','44.jpg','45.jpg','46.jpg','47.jpg','48.jpg','49.jpg','50.jpg','51.jpg','52.jpg','53.jpg','54.jpg','55.jpg','56.jpg','57.jpg','58.jpg','59.jpg','60.jpg','61.jpg','62.jpg','63.jpg','64.jpg','65.jpg','66.jpg','67.jpg','68.jpg','69.jpg','70.jpg','71.jpg','72.jpg','73.jpg','74.jpg','75.jpg','76.jpg','77.jpg','78.jpg','79.jpg','80.jpg','81.jpg','82.jpg','83.jpg','84.jpg','85.jpg','86.jpg','87.jpg','88.jpg','89.jpg','90.jpg','91.jpg','92.jpg','93.jpg','94.jpg','95.jpg','96.jpg','97.jpg','98.jpg','99.jpg','100.jpg','101.jpg','102.jpg','103.jpg','104.jpg','105.jpg','106.jpg','107.jpg','108.jpg','109.jpg','110.jpg','111.jpg','112.jpg','113.jpg','114.jpg','115.jpg','116.jpg','117.jpg','118.jpg','119.jpg','120.jpg','121.jpg','122.jpg','123.jpg','124.jpg','125.jpg','126.jpg','127.jpg','128.jpg','129.jpg','130.jpg','131.jpg','132.jpg','133.jpg','134.jpg','135.jpg'];
    var ImgAry5=['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg','9.jpg','10.jpg','11.jpg','12.jpg','13.jpg','14.jpg','15.jpg','16.jpg','17.jpg','18.jpg','19.jpg','20.jpg','21.jpg','22.jpg','23.jpg','24.jpg','25.jpg','26.jpg','27.jpg','28.jpg','29.jpg','30.jpg','32.jpg','33.jpg','34.jpg','35.jpg','36.jpg','37.jpg','38.jpg','39.jpg','40.jpg','41.jpg','42.jpg','43.jpg','44.jpg','45.jpg','46.jpg','47.jpg','48.jpg','49.jpg','50.jpg','51.jpg','52.jpg','53.jpg','54.jpg','55.jpg','56.jpg','57.jpg','58.jpg','59.jpg','60.jpg','61.jpg','62.jpg','63.jpg','64.jpg','65.jpg','66.jpg','67.jpg','68.jpg','69.jpg','70.jpg','71.jpg','72.jpg','73.jpg','74.jpg','75.jpg','76.jpg','77.jpg','78.jpg','79.jpg','80.jpg','81.jpg','82.jpg','83.jpg','84.jpg','85.jpg','86.jpg','87.jpg','88.jpg','89.jpg','90.jpg','91.jpg','92.jpg','93.jpg','94.jpg','95.jpg','96.jpg','97.jpg','98.jpg','99.jpg','100.jpg','101.jpg','102.jpg','103.jpg','104.jpg','105.jpg','106.jpg','107.jpg','108.jpg','109.jpg','110.jpg','111.jpg','112.jpg','113.jpg','114.jpg','115.jpg','116.jpg','117.jpg','118.jpg','119.jpg','120.jpg','121.jpg','122.jpg','123.jpg','124.jpg','125.jpg','126.jpg','127.jpg','128.jpg','129.jpg','130.jpg','131.jpg','132.jpg','133.jpg','134.jpg','135.jpg'];
    var ImgAry6=['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg','9.jpg','10.jpg','11.jpg','12.jpg','13.jpg','14.jpg','15.jpg','16.jpg','17.jpg','18.jpg','19.jpg','20.jpg','21.jpg','22.jpg','23.jpg','24.jpg','25.jpg','26.jpg','27.jpg','28.jpg','29.jpg','30.jpg','32.jpg','33.jpg','34.jpg','35.jpg','36.jpg','37.jpg','38.jpg','39.jpg','40.jpg','41.jpg','42.jpg','43.jpg','44.jpg','45.jpg','46.jpg','47.jpg','48.jpg','49.jpg','50.jpg','51.jpg','52.jpg','53.jpg','54.jpg','55.jpg','56.jpg','57.jpg','58.jpg','59.jpg','60.jpg','61.jpg','62.jpg','63.jpg','64.jpg','65.jpg','66.jpg','67.jpg','68.jpg','69.jpg','70.jpg','71.jpg','72.jpg','73.jpg','74.jpg','75.jpg','76.jpg','77.jpg','78.jpg','79.jpg','80.jpg','81.jpg','82.jpg','83.jpg','84.jpg','85.jpg','86.jpg','87.jpg','88.jpg','89.jpg','90.jpg','91.jpg','92.jpg','93.jpg','94.jpg','95.jpg','96.jpg','97.jpg','98.jpg','99.jpg','100.jpg','101.jpg','102.jpg','103.jpg','104.jpg','105.jpg','106.jpg','107.jpg','108.jpg','109.jpg','110.jpg','111.jpg','112.jpg','113.jpg','114.jpg','115.jpg','116.jpg','117.jpg','118.jpg','119.jpg','120.jpg','121.jpg','122.jpg','123.jpg','124.jpg','125.jpg','126.jpg','127.jpg','128.jpg','129.jpg','130.jpg','131.jpg','132.jpg','133.jpg','134.jpg','135.jpg'];
    var ImgAry7=['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg','9.jpg','10.jpg','11.jpg','12.jpg','13.jpg','14.jpg','15.jpg','16.jpg','17.jpg','18.jpg','19.jpg','20.jpg','21.jpg','22.jpg','23.jpg','24.jpg','25.jpg','26.jpg','27.jpg','28.jpg','29.jpg','30.jpg','32.jpg','33.jpg','34.jpg','35.jpg','36.jpg','37.jpg','38.jpg','39.jpg','40.jpg','41.jpg','42.jpg','43.jpg','44.jpg','45.jpg','46.jpg','47.jpg','48.jpg','49.jpg','50.jpg','51.jpg','52.jpg','53.jpg','54.jpg','55.jpg','56.jpg','57.jpg','58.jpg','59.jpg','60.jpg','61.jpg','62.jpg','63.jpg','64.jpg','65.jpg','66.jpg','67.jpg','68.jpg','69.jpg','70.jpg','71.jpg','72.jpg','73.jpg','74.jpg','75.jpg','76.jpg','77.jpg','78.jpg','79.jpg','80.jpg','81.jpg'];
    
    
    
    // The SelAry is used to populate the Select Images SelectList
    var SelAry=[];
    // Each field is an array defining an option
    // field 0 = the text to be displayed in the option
    // field 1 = the directory path for the images
    // field 2 = the image file names]
    SelAry[0]=[];
    SelAry[1]=['The Pilot Episode','http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/memory/pilot1/',ImgAry];
    SelAry[2]=['The Origin Story','http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/memory/tos1/',ImgAry2];
    SelAry[3]=['The Culex Experiment','http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/memory/tce1/',ImgAry3];
    SelAry[4]=['Monsoon Man','http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/memory/mm1/',ImgAry4];
    SelAry[5]=['The Rameses Connection','http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/memory/trc1/',ImgAry5];
    SelAry[6]=['The Living Stones','http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/memory/tlstones1/',ImgAry6];
    SelAry[7]=['Audio Series','http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/memory/audio1/',ImgAry7];
    
    
    var j = 0
    var q = ImgAry.length;
    
    var preBuffer = new Array()
    for (i = 0; i < q; i++){
       preBuffer[i] = new Image()
       preBuffer[i].src = ImgAry[i]
    }
    
    var whichImage = Math.round(Math.random()*(q-1));
    function showImage(){
    document.write('<img src="'+ImgAry[whichImage]+'" width=\"640\" height=\"456\">');
    }
    
    
    //  End -->
    </script>
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    I guess i really don't understand your question you showed code whats wrong with the code?

    Comment

    • iam_clint
      Recognized Expert Top Contributor
      • Jul 2006
      • 1207

      #3
      Code:
      function showImage(whichstyle){
      var style = SelAry[whichstyle];
      style = style[1];
      document.write('<img src="'+style+ImgAry[whichImage]+'" width=\"640\" height=\"456\">');
      }
      
      //  End -->
      </script>
      <input type="button" onclick="showImage(1);" value="click me!">
      you mean something like this?

      Comment

      • tpgames
        Contributor
        • Jan 2007
        • 783

        #4
        I can't get any images to show up. I'm trying to get the code to recognize the array and recognize the image URL. I'm attempting to make it so the JS is on its own page and is called to the html page.

        The user would have a menu to select a theme from. I've not put that code in yet, forgot. Babysitting and new to JS = Confusion. LOL Thanks!

        The Link to page

        This is what I did on another page:
        Page 1

        The images show up, but don't use an image array I like. I'd rather just use images array whereby I only have to change the link and title to get what I want, which is why I copied code from a memory game.

        Comment

        • tpgames
          Contributor
          • Jan 2007
          • 783

          #5
          Better idea: Forget selecting the theme from within the page. Instead, use simple html link to theme instead of selection box that doesn't work.

          Use page 1 script. But, alter it to handle Arrays in this format:
          Code:
          var ImgAry=new Array();
          // Each field is an array defining an option
          // field 0 = the directory path for the images
          // field 1 = the image file names
          // field 2 = width and height]
          ImgAry[0]=['http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/memory/tlstones1/',ImgAry1, 640,556];
          ImgAry[1]=['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg','9.jpg','10.jpg','11.jpg','12.jpg','13.jpg','14.jpg','15.jpg','16.jpg','17.jpg','18.jpg','19.jpg','20.jpg','21.jpg','22.jpg','23.jpg','24.jpg','25.jpg','26.jpg','27.jpg','28.jpg','29.jpg','30.jpg','32.jpg','33.jpg','34.jpg','35.jpg','36.jpg','37.jpg','38.jpg','39.jpg','40.jpg','41.jpg','42.jpg','43.jpg','44.jpg','45.jpg','46.jpg','47.jpg','48.jpg','49.jpg','50.jpg','51.jpg','52.jpg','53.jpg','54.jpg','55.jpg','56.jpg','57.jpg','58.jpg','59.jpg','60.jpg','61.jpg','62.jpg','63.jpg','64.jpg','65.jpg','66.jpg','67.jpg','68.jpg','69.jpg','70.jpg','71.jpg','72.jpg','73.jpg','74.jpg','75.jpg','76.jpg','77.jpg','78.jpg','79.jpg','80.jpg','81.jpg','82.jpg','83.jpg','84.jpg','85.jpg','86.jpg','87.jpg','88.jpg','89.jpg','90.jpg','91.jpg','92.jpg','93.jpg','94.jpg','95.jpg','96.jpg','97.jpg','98.jpg','99.jpg','100.jpg','101.jpg','102.jpg','103.jpg','104.jpg','105.jpg','106.jpg','107.jpg','108.jpg','109.jpg','110.jpg','111.jpg','112.jpg','113.jpg','114.jpg','115.jpg','116.jpg','117.jpg','118.jpg','119.jpg','120.jpg','121.jpg','122.jpg','123.jpg','124.jpg','125.jpg','126.jpg','127.jpg','128.jpg','129.jpg','130.jpg','131.jpg','132.jpg','133.jpg','134.jpg','135.jpg'];
          How do I do this? I'd like it to randomly choose an image in the folder. The above code does NOT work!
          Currently, I get the error
          http://www.tpgames.net/gaming/2/word/cipher/f/undefined

          Current Page 1
          Thanks!

          Comment

          • tpgames
            Contributor
            • Jan 2007
            • 783

            #6
            NEW CODE:

            Code:
            var theTPImg = new Array();
            ImgUrl[0]=['http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/memory/tlstones1/'];
            theTPImg[1]=['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg','9.jpg','10.jpg','11.jpg','12.jpg','13.jpg','14.jpg','15.jpg','16.jpg','17.jpg','18.jpg','19.jpg','20.jpg','21.jpg','22.jpg','23.jpg','24.jpg','25.jpg','26.jpg','27.jpg','28.jpg','29.jpg','30.jpg','32.jpg','33.jpg','34.jpg','35.jpg','36.jpg','37.jpg','38.jpg','39.jpg','40.jpg','41.jpg','42.jpg','43.jpg','44.jpg','45.jpg','46.jpg','47.jpg','48.jpg','49.jpg','50.jpg','51.jpg','52.jpg','53.jpg','54.jpg','55.jpg','56.jpg','57.jpg','58.jpg','59.jpg','60.jpg','61.jpg','62.jpg','63.jpg','64.jpg','65.jpg','66.jpg','67.jpg','68.jpg','69.jpg','70.jpg','71.jpg','72.jpg','73.jpg','74.jpg','75.jpg','76.jpg','77.jpg','78.jpg','79.jpg','80.jpg','81.jpg','82.jpg','83.jpg','84.jpg','85.jpg','86.jpg','87.jpg','88.jpg','89.jpg','90.jpg','91.jpg','92.jpg','93.jpg','94.jpg','95.jpg','96.jpg','97.jpg','98.jpg','99.jpg','100.jpg','101.jpg','102.jpg','103.jpg','104.jpg','105.jpg','106.jpg','107.jpg','108.jpg','109.jpg','110.jpg','111.jpg','112.jpg','113.jpg','114.jpg','115.jpg','116.jpg','117.jpg','118.jpg','119.jpg','120.jpg','121.jpg','122.jpg','123.jpg','124.jpg','125.jpg','126.jpg','127.jpg','128.jpg','129.jpg','130.jpg','131.jpg','132.jpg','133.jpg','134.jpg','135.jpg'];
            
            var newBanner = 0;
            var totalBan = theTPImg.length;
            
            function cycleBan() {
              newBanner++;
              if (newBanner == totalBan) {
            	newBanner = 0;
              }
              document.banner.src= "'+ImgUrl+' 'theTPImg[newBanner]'";
              // set the time below for length of image display
              // i.e., "4*1000" is 4 seconds
              setTimeout("cycleBan()", 4*1000);
            }
            window.onload=cycleBan;

            Found here

            The issue: It says the url is wrong. Actually, I probably have
            this code wrong:
            Code:
              document.banner.src= "'+ImgUrl+' 'theTPImg[newBanner]'";
            Its not recognizing the url variable. How should this code be written? Thanks!

            This code would have the array I want.

            Comment

            • tpgames
              Contributor
              • Jan 2007
              • 783

              #7
              CORRECTION:
              The issue: Not changing the images at all. Only displays 1.jpg
              This code is probably wrong, but don't know how to fix it.
              Code:
                document.banner.src= "'+ImgUrl+' 'theTPImg[newBanner]'";
              Its not recognizing the url variable. How should this code be written? Thanks!

              This code would have the array I want.
              (try editing, got the edit box but then it timed out and gave me the can not edit page! Foolish program. Should not time out within 30 seconds of saying I'm within the time limit!)

              Comment

              • Romulo NF
                New Member
                • Nov 2006
                • 54

                #8
                ok.. lets forget about what you already have!
                i tried to look at your code and im even more confused now :P

                can you try to explain exactly what you want to do?

                Comment

                • tpgames
                  Contributor
                  • Jan 2007
                  • 783

                  #9
                  Clarification:
                  I'm trying to avoid having to add the URL of the image to every single image in the array and avoid making the image array
                  [html]
                  http://www.url.com/name1.jpg., http://www.url.com/name2.jpg, ect. for all 135 images.
                  [/html]
                  (Just in case it tried treating it as html anyhow, I added tags.)

                  Comment

                  • tpgames
                    Contributor
                    • Jan 2007
                    • 783

                    #10
                    This uses the original variable names with bannerImg.
                    The // indicates the original scripts array, with the images in the same folder as the script. My images are hosted at photob...dotCom , instead of at my site. I'm attempting to use an array to define the URL where the images are located, and a Array of the image names. I'm also attempting to have the code recognize the url of the images and attach it to the image names and display this image. Currently, the images will rotate like in a banner.

                    Code:
                    var bannerImg = new Array();
                      // Enter the names of the images below
                     // bannerImg[0]="image_jss.gif";
                     // bannerImg[1]="image_js.gif";
                     // bannerImg[2]="image_wr.gif";
                    
                    
                    ImgUrl[0]=['http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/memory/tlstones1/'];
                    bannerImg[1]=['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg','9.jpg','10.jpg','11.jpg','12.jpg','13.jpg','14.jpg','15.jpg','16.jpg','17.jpg','18.jpg','19.jpg','20.jpg','21.jpg','22.jpg','23.jpg','24.jpg','25.jpg','26.jpg','27.jpg','28.jpg','29.jpg','30.jpg','32.jpg','33.jpg','34.jpg','35.jpg','36.jpg','37.jpg','38.jpg','39.jpg','40.jpg','41.jpg','42.jpg','43.jpg','44.jpg','45.jpg','46.jpg','47.jpg','48.jpg','49.jpg','50.jpg','51.jpg','52.jpg','53.jpg','54.jpg','55.jpg','56.jpg','57.jpg','58.jpg','59.jpg','60.jpg','61.jpg','62.jpg','63.jpg','64.jpg','65.jpg','66.jpg','67.jpg','68.jpg','69.jpg','70.jpg','71.jpg','72.jpg','73.jpg','74.jpg','75.jpg','76.jpg','77.jpg','78.jpg','79.jpg','80.jpg','81.jpg','82.jpg','83.jpg','84.jpg','85.jpg','86.jpg','87.jpg','88.jpg','89.jpg','90.jpg','91.jpg','92.jpg','93.jpg','94.jpg','95.jpg','96.jpg','97.jpg','98.jpg','99.jpg','100.jpg','101.jpg','102.jpg','103.jpg','104.jpg','105.jpg','106.jpg','107.jpg','108.jpg','109.jpg','110.jpg','111.jpg','112.jpg','113.jpg','114.jpg','115.jpg','116.jpg','117.jpg','118.jpg','119.jpg','120.jpg','121.jpg','122.jpg','123.jpg','124.jpg','125.jpg','126.jpg','127.jpg','128.jpg','129.jpg','130.jpg','131.jpg','132.jpg','133.jpg','134.jpg','135.jpg'];
                    
                    //The rest of the original code is below.
                    
                    var newBanner = 0;
                    var totalBan = bannerImg.length;
                    
                    function cycleBan() {
                      newBanner++;
                      if (newBanner == totalBan) {
                    	newBanner = 0;
                      }
                      document.banner.src=bannerImg[newBanner];
                      // set the time below for length of image display
                      // i.e., "4*1000" is 4 seconds
                      setTimeout("cycleBan()", 4*1000);
                    }
                    window.onload=cycleBan;
                    What I tried to do in my code was get ImgUrl and bannerImg to work together to display an image. My code was wrong, and don't know how it should be written. Here, I left my code out as it was all wrong.
                    Thanks!

                    Comment

                    • Romulo NF
                      New Member
                      • Nov 2006
                      • 54

                      #11
                      Code:
                      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
                      
                      <html>
                      <head>
                      <title>Random images same url</title>
                      </head>
                      
                      <style>
                      
                      #bgHolder {height:12px; width:12px; display:block; overflow:hidden;}
                      
                      </style>
                      
                      <body>
                      
                      <div id="bgHolder">
                      
                      </div>
                      
                      </body>
                      
                      <script>
                      
                      imgName = new Array()
                      imgName[0] = "yellow"
                      imgName[1] = "blue"
                      imgName[2] = "orange"
                      imgName[3] = "purple"
                      imgName[4] = "brown"
                      
                      contextPath = "bgs/";
                      extension = ".gif";
                      current = 0;
                      
                      window.onload = randomizeImage
                      
                      function randomizeImage() {
                      
                      changeImg()
                      }
                      
                      function changeImg() {
                      holder = document.getElementById("bgHolder");
                      holder.style.background="url(" + contextPath + imgName[current] + extension + ")";
                      
                      if (current < imgName.length-1) {	current = current+1 }
                      
                      else { current = 0 }
                      
                      setTimeout('randomizeImage()',2000);
                      }
                      
                      </script>
                      
                      </html>
                      Something like this?
                      I dont got why you were using one array to store a single path... you can use just a variable for that instead of the array[0]

                      Comment

                      • tpgames
                        Contributor
                        • Jan 2007
                        • 783

                        #12
                        I was trying to save typing by using some code I had from another game. If I can use the image array in the format I had it, then I don't have to type in 135 [# here]'s.

                        I'll try your code and see how it works, then submit a new reply.

                        Comment

                        • tpgames
                          Contributor
                          • Jan 2007
                          • 783

                          #13
                          I can't get it to work using this:
                          Code:
                          imgName[0] = ['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg','9.jpg','10.jpg','11.jpg','12.jpg','13.jpg','14.jpg','15.jpg','16.jpg','17.jpg','18.jpg','19.jpg','20.jpg','21.jpg','22.jpg','23.jpg','24.jpg','25.jpg','26.jpg','27.jpg','28.jpg','29.jpg','30.jpg','32.jpg','33.jpg','34.jpg','35.jpg','36.jpg','37.jpg','38.jpg','39.jpg','40.jpg','41.jpg','42.jpg','43.jpg','44.jpg','45.jpg','46.jpg','47.jpg','48.jpg','49.jpg','50.jpg','51.jpg','52.jpg','53.jpg','54.jpg','55.jpg','56.jpg','57.jpg','58.jpg','59.jpg','60.jpg','61.jpg','62.jpg','63.jpg','64.jpg','65.jpg','66.jpg','67.jpg','68.jpg','69.jpg','70.jpg','71.jpg','72.jpg','73.jpg','74.jpg','75.jpg','76.jpg','77.jpg','78.jpg','79.jpg','80.jpg','81.jpg','82.jpg','83.jpg','84.jpg','85.jpg','86.jpg','87.jpg','88.jpg','89.jpg','90.jpg','91.jpg','92.jpg','93.jpg','94.jpg','95.jpg','96.jpg','97.jpg','98.jpg','99.jpg','100.jpg','101.jpg','102.jpg','103.jpg','104.jpg','105.jpg','106.jpg','107.jpg','108.jpg','109.jpg','110.jpg','111.jpg','112.jpg','113.jpg','114.jpg','115.jpg','116.jpg','117.jpg','118.jpg','119.jpg','120.jpg','121.jpg','122.jpg','123.jpg','124.jpg','125.jpg','126.jpg','127.jpg','128.jpg','129.jpg','130.jpg','131.jpg','132.jpg','133.jpg','134.jpg','135.jpg'];
                          It will only work if I use exactly your set up which means a lot of coding. However, I'd only have to do it once. I'd have to get rid of the .jpg, and type in
                          Code:
                          imgName[0] = ['1']; imgName[1] = ['2']; ect. 135 times!
                          I just thought there was a short cut somewheres. Some simple line of code that I had wrong or something. Thanks!

                          Comment

                          • tpgames
                            Contributor
                            • Jan 2007
                            • 783

                            #14
                            I typed in that bottom code wrong! Sorry! But the point is, I'd have to type in what you did 135 times.

                            Comment

                            • tpgames
                              Contributor
                              • Jan 2007
                              • 783

                              #15
                              It doesn't show the entire image either. It only shows a tiny corner.

                              5.html

                              Comment

                              Working...