Close

Results 1 to 18 of 18
  1. #1
    DF Member fat_lee's Avatar
    Join Date
    Feb 2003
    Location
    Manchester
    Posts
    39
    Thanks
    0
    Thanked:        0
    Karma Level
    0

    Default Help with java script

    Is there any way of changing this java script to HTML so i can use it on my sig?

    PHP Code:
     <HEAD>

    <
    SCRIPT LANGUAGE="JavaScript">
    <!-- 
    Begin
    var rand1 0;
    var 
    useRand 0;

    images = new Array;
    images[1] = new Image();
    images[1].src "http://www.lee404s.dsl.pipex.com/tatu2.jpg";
    images[2] = new Image();
    images[2].src "http://www.lee404s.dsl.pipex.com/tatu.jpg";


    function 
    swapPic() {
    var 
    imgnum images.length 1;
    do {
    var 
    randnum Math.random();
    rand1 Math.round((imgnum 1) * randnum) + 1;
    } while (
    rand1 == useRand);
    useRand rand1;
    document.randimg.src images[useRand].src;
    }
    // End -->
    </script>
    </
    HEAD>

    <
    BODY OnLoad="swapPic()"

  2. #2
    DF VIP Member graham.edmon's Avatar
    Join Date
    May 2001
    Location
    Edinburgh
    Posts
    263
    Thanks
    0
    Thanked:        0
    Karma Level
    290

    Default

    use a graphics program to make the two pictures into a animated gif file....

  3. #3
    DF VIP Member WTD's Avatar
    Join Date
    Mar 2001
    Location
    Tokyo, Japan
    Posts
    3,256
    Thanks
    0
    Thanked:        0
    Karma Level
    492

    Default

    Here you go

  4. #4
    DF Member fat_lee's Avatar
    Join Date
    Feb 2003
    Location
    Manchester
    Posts
    39
    Thanks
    0
    Thanked:        0
    Karma Level
    0

    Default

    Thanks guys!!

    But is there anyway of doing it so it changes on refresh?
    Last edited by fat_lee; 24th February 2003 at 07:08 PM.

  5. #5
    DF VIP Member WTD's Avatar
    Join Date
    Mar 2001
    Location
    Tokyo, Japan
    Posts
    3,256
    Thanks
    0
    Thanked:        0
    Karma Level
    492

    Default

    Yeah there is using PHP, but your host doesn't provide PHP enabled web space

  6. #6
    DF Member fat_lee's Avatar
    Join Date
    Feb 2003
    Location
    Manchester
    Posts
    39
    Thanks
    0
    Thanked:        0
    Karma Level
    0

    Default

    If i had a host that did allow PHP could i do it then? even though the forum doesnt allow PHP sigs?

  7. #7
    DF VIP Member WTD's Avatar
    Join Date
    Mar 2001
    Location
    Tokyo, Japan
    Posts
    3,256
    Thanks
    0
    Thanked:        0
    Karma Level
    492

    Default

    Yeah because using PHP and the GD Image library you can create an image, and output it to the browser as an Image, as far as a client is concerned, the php script is an image, as all processing is done server side..

    Take a look at this script here

  8. #8
    DF Member fat_lee's Avatar
    Join Date
    Feb 2003
    Location
    Manchester
    Posts
    39
    Thanks
    0
    Thanked:        0
    Karma Level
    0

    Default

    Thats all greek to me mate, never even looked at PHP is it worth looking into as a Hobby language, im not employed in the computer industry nor do i ever want to be, but i like web site building. is it worth bothering?

    on a second note you could code that up so i can use it in a sig could you? i know its cheeky but it would look cool

  9. #9
    DF VIP Member WTD's Avatar
    Join Date
    Mar 2001
    Location
    Tokyo, Japan
    Posts
    3,256
    Thanks
    0
    Thanked:        0
    Karma Level
    492

    Default

    lol it is coded up in a script already

    Find some PHP enabled webspace, which has GD Image capabilities and I will tell you how to get it working.

  10. #10
    DF Probation Ryan5262's Avatar
    Join Date
    Nov 2002
    Location
    Scotland
    Posts
    680
    Thanks
    0
    Thanked:        0
    Karma Level
    306

    Default

    i got some php web space and if its just that file i could host it for you ! just gives a shout

  11. #11
    DF Member fat_lee's Avatar
    Join Date
    Feb 2003
    Location
    Manchester
    Posts
    39
    Thanks
    0
    Thanked:        0
    Karma Level
    0

    Default

    WTD sorry i meant how do i tell it where to put my images etc, i dont understand PHP. it says

    $image[$i] = $im; // Add that image filename to the array
    $i++; // Increment our counter

    does that mean i write it as.

    $image[$i] = $im; //www.lee404s.dsl.pipex.com/tatu.jpg
    $image[$i] = $im; //www.lee404s.dsl.pipex.com/tatu2jpg
    $i++; // Increment our counter

    and then paste the lot onto the right kind of web space? or am i barking up the wrong tree?

    Ryan thanks for the offer mate i might just take you up on it

  12. #12
    DF VIP Member WTD's Avatar
    Join Date
    Mar 2001
    Location
    Tokyo, Japan
    Posts
    3,256
    Thanks
    0
    Thanked:        0
    Karma Level
    492

    Default

    Save this as signature.php

    PHP Code:
    <?php 
    Header
    ("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); 
    Header("Expires: Thu, 19 Nov 1981 08:52:00 GMT"); 
    Header("Pragma: no-cache"); 
    Header("Content-Type: image/gif"); 
    // Header info, forces no cache and image type of GIF 

    $dir "images" // Define the subdirectory to where we store the images.. 

    srand((double)microtime()*1000000); // Set a random seed up 
    $i 0// Set our counter to 0 
    $dirHandle opendir($dir); // Open the images directory 
    while(($im readdir($dirHandle))) // Read in image filenames 

    if(
    $im != ".." && $im != "."// Don't read in the 2 directories ".." and "." 

    $image[$i] = $im// Add that image filename to the array 
    $i++; // Increment our counter 


    closedir($dirHandle); // Close the directory handle 
    $n rand(0,(count($image)-1)); // Create a random number from 0 to the size of the array 

    if(!readfile($dir."/".$image[$n])) // Read in a file and output it to the output buffer.. 
    readfile($dir."error/error.gif"); // If we can't for some reason use the error.gif file in the error directory 
    ?>
    Put that in a directory with all the images (in gif format) that you want it to open randomly in a subdirectory called "images" on each refresh and bobs your uncle...

  13. #13
    DF Member fat_lee's Avatar
    Join Date
    Feb 2003
    Location
    Manchester
    Posts
    39
    Thanks
    0
    Thanked:        0
    Karma Level
    0

    Default

    Sorry mate you lost me again. when you say put that in the same directory, do you mean on my web space? how would i put it in. on a text file?

    http://www.mywebspace.com/folder/tex...ithphponit.txt
    www.mywebspace.com/folder/pic1.gif
    www.mywebspace.com/folder/pic2.gif

    and then i put this file

    http://www.mywebspace.com/folder/tex...ithphponit.txt

    as my sig in image tags and i will get those two pictures on random refresh?

  14. #14
    DF VIP Member WTD's Avatar
    Join Date
    Mar 2001
    Location
    Tokyo, Japan
    Posts
    3,256
    Thanks
    0
    Thanked:        0
    Karma Level
    492

    Default

    All that code in my post between the lines should go into a file called signature.php

    Put that in a folder in some PHP webserver.
    In the same folder have a folder called images.
    In the images folder put in all the images you want to display. Like image1.gif, image2.gif, image3.gif, image4.gif

    Then in your sig put this

    [ IMG]http://yourdomain/yourfolder/signature.php[ /IMG]

    and it will show you a random image file when you refresh each page.

    like I said before, you need PHP enabled webspace, and pipex web space isn't enabled. Hopefully ryan will read this and set this up for you

  15. #15
    DF Member fat_lee's Avatar
    Join Date
    Feb 2003
    Location
    Manchester
    Posts
    39
    Thanks
    0
    Thanked:        0
    Karma Level
    0

    Default

    It doesnt seem to be working for me mate. ive got that PHP file here

    http://members.lycos.co.uk/lee404s/signature.php

    and in the same folder there's another folder called images with 2 pictures in mate and all i get is a red x?

  16. #16
    DF Member fat_lee's Avatar
    Join Date
    Feb 2003
    Location
    Manchester
    Posts
    39
    Thanks
    0
    Thanked:        0
    Karma Level
    0

    Default

    Hi mate

    i got it working, thank you very much

  17. #17
    DF VIP Member WTD's Avatar
    Join Date
    Mar 2001
    Location
    Tokyo, Japan
    Posts
    3,256
    Thanks
    0
    Thanked:        0
    Karma Level
    492

    Default

    Excellent

  18. #18
    DF Member fat_lee's Avatar
    Join Date
    Feb 2003
    Location
    Manchester
    Posts
    39
    Thanks
    0
    Thanked:        0
    Karma Level
    0

    Default

    Just been told www.hostmysig.com offer it for nothing lol oh well atleast i learnt something,

Similar Threads

  1. nhl 2003 - razor - crack.exe is a script virus?
    By petegas in forum PC Gaming
    Replies: 1
    Last Post: 6th October 2002, 10:29 PM
  2. Java console??
    By Jaffa in forum PC Problems
    Replies: 3
    Last Post: 26th September 2002, 02:14 AM
  3. Superman : new script review
    By TigerShark in forum Movie Talk
    Replies: 2
    Last Post: 25th September 2002, 01:50 PM
  4. Java Idea?
    By Roo in forum Unlocking Questions & Solutions
    Replies: 0
    Last Post: 8th September 2002, 06:55 PM

Social Networking 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
  •