Recommendations on a "pic of the day" java app for web page?

Discussion in 'Photoshop Tutorials' started by spectre, Jun 5, 2004.

  1. spectre

    spectre Guest

    TIA
     
    spectre, Jun 5, 2004
    #1
    1. Advertisements

  2. spectre

    Mike Russell Guest

    Google for javascript random.

    This was not written by me, but was posted by Joe Greene some time ago in a
    different news group.

    /*
    Try this. I wrote a function to generate a random number:
    */
    function Roll_Die(DSize){
    var DRoll=0;
    for (I=0;I<DSize;I++){
    DRoll+=Math.round(Math.random());
    } return DRoll
    }
    /*
    Now Given the use of the above function, create an array of image
    filenames
    */
    var MyImages=new Array();
    MyImages[0]="foo.gif";
    MyImages[1]="bar.jpg";
    MyImages[2]="foo-bar.gif";

    /*
    Next assuming you are manipulating the first image on your page call this
    function to randomly change pictures.
    */
    function RandomPix(){
    var P=Roll_Die(MyImages.length);
    document.images[0].src="http://my.server.com/my/imge/folder/"+MyImages[P];

    }
    /*
    You can call the function in onLoad= to only select at load time, or you
    can create another function with a setInterval() calling itself to
    randomly change images periodically. Note: if your going to change images
    at intervals it's recommened to create a hidden layer which loads them
    all, in order to minimize the lage when it changes pictures....
    */
     
    Mike Russell, Jun 7, 2004
    #2
    1. Advertisements

  3. spectre

    Tacit Guest

    Google for javascript random.
    The problem with a randomizer like this is that it must be hard-coded with the
    names of the images, and it increases the size of the HTML file (significantly,
    if there are many images).

    I have written a Perl random image CGI which allows you to dump images into a
    folder on the server, and grabs one of the images from that folder at random;
    in order to use it, you must (of course) have a Web host which permits you to
    use CGI scripts. It's freeware, and available for download from my Web site at

    www.xeromag.com/fvshare.html
     
    Tacit, Jun 7, 2004
    #3
  4. The .zip link points to the .sit file :).

    Cheers,
    Nicholas Sherlock
     
    Nicholas Sherlock, Jun 7, 2004
    #4
  5. spectre

    Tacit Guest

    The .zip link points to the .sit file :).

    Whoops! So it does. It's fixed now.
     
    Tacit, Jun 8, 2004
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.