PLEASE HELP ! Randomizing A Banner Script

Discussion in 'JavaScript' started by locals, Aug 31, 2008.

  1. #1
    Can you please help me make this banner display, display random banners instead of the first banner on the list every time ? THANKS !

    var ImageCount = 5; // ***** Change this to the total number of images loaded above ***** //
    var ImageDelay = 6000; // ***** Set this to the delay interval desired. 5000 = 5 seconds. //
    var LinkTarget = "_self" // ***** Defines where you want linked page to open. _self, _blank, _top, etc //
    var ImageIndex = 0; // DO NOT ALTER //
    var FirstLoad = 0; // DO NOT ALTER //
    var QuickStartID = 0; // DO NOT ALTER //
    var htmlString = "" // DO NOT ALTER //

    // This function rotates the banner //
    function ImageChange()

    {

    htmlString = '<center>';
    htmlString = htmlString + '<font face = "Verdana" size="2">'; // Font and Font Size for caption may be changed here //
    htmlString = htmlString +'<a target="_blank"';
    htmlString = htmlString + LinkTarget;
    htmlString = htmlString + '" href="';
    htmlString = htmlString + ImageLoad[ImageIndex][0];
    htmlString = htmlString + '"><img border="0" src="'; // Image border size may be changed here //
    htmlString = htmlString + ImageLoad[ImageIndex][1];
    htmlString = htmlString + '"></a><br>';
    htmlString = htmlString + ImageLoad[ImageIndex][2];
    htmlString = htmlString + '</font>';
    htmlString = htmlString + '</center>';

    document.getElementById('MagicImage').innerHTML = htmlString;

    if(ImageIndex == ImageCount - 1) // This statement increments image displayed and resets if displaying last image //
    {
    ImageIndex= 0;
    }
    else
    {
    ImageIndex++;
    }

    if(FirstLoad == 0) // Determins if this is the first time function has run. //
    {
    SlowFinish();
    }

    }
    // End Funtion //

    // This function ensures first banner is displayted without a delay //
    function QuickStart()
    {
    QuickStartID=setInterval("ImageChange()", 1000);
    }
    // End Funtion //

    // This function sets display rate to user defined speed //
    function SlowFinish()
    {
    clearInterval(QuickStartID);
    FirstLoad = 1;
    setInterval("ImageChange()", ImageDelay);
    }
    // End Funtion //

    QuickStart()
     
    locals, Aug 31, 2008 IP
  2. Daemn

    Daemn Peon

    Messages:
    27
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    http://www.php.net/rand
     
    Daemn, Sep 4, 2008 IP
  3. locals

    locals Well-Known Member

    Messages:
    1,677
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    153
    #3
    just out of curitosity how does installing the random number code into this script prevent hackers ? and where do i place this ?

    my hosting company said some one somehow downloaded "malicious files" to my server ???
     
    locals, Sep 4, 2008 IP
  4. temp2

    temp2 Well-Known Member

    Messages:
    1,231
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    150
    Digital Goods:
    2
    #4
    temp2, Sep 5, 2008 IP
  5. locals

    locals Well-Known Member

    Messages:
    1,677
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    153
    #5
    i will check out these sites THANKS FOR YOUR HELP !
     
    locals, Sep 5, 2008 IP
  6. TKY_Publishing

    TKY_Publishing Well-Known Member

    Messages:
    270
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    Digital Goods:
    7
    Articles:
    28
    #6
    This SHOULD be what you're looking for;

    
    
    var ImageCount  = 6;   //  *****  Change this to the total number of images loaded above  *****   // 
    var ImageDelay  = 7000;   //  *****  Set this to the delay interval desired.  5000 = 5 seconds.   // 
    var LinkTarget  = "_blank"  //  *****  Defines where you want linked page to open. _self, _blank, _top, etc //
    var ImageIndex  = 0;   //  DO NOT ALTER //
    var FirstLoad   = 0;   //  DO NOT ALTER //
    var QuickStartID  = 0;     //  DO NOT ALTER //
    var htmlString   = ""   //  DO NOT ALTER  //
    var randomnumber = 0;   //  DO NOT ALTER //
    
    //  This function rotates the banner  //
    function ImageChange()
    
    {  
    
    htmlString = '<center>';
    htmlString = htmlString + '<font face = "Verdana" size="3">';  //  Font and Font Size for caption may be changed here //
    htmlString = htmlString +'<a target="';
    htmlString = htmlString + LinkTarget;
    htmlString = htmlString + '" href="';
    htmlString = htmlString + ImageLoad[ImageIndex][0];
    htmlString = htmlString + '"><img border="0" src="';    //  Image border size may be changed here    // 
    htmlString = htmlString + ImageLoad[ImageIndex][1];
    htmlString = htmlString + '"></a><br>';
    htmlString = htmlString + ImageLoad[ImageIndex][2];
    htmlString = htmlString + '</font>';
    htmlString = htmlString + '</center>';  
    
    document.getElementById('MagicImage').innerHTML = htmlString;     
    
    ImageIndex = Math.floor(Math.random()*ImageCount);                    
    
    if(FirstLoad == 0)      //  Determins if this is the first time function has run.   // 
    {
    SlowFinish();
    }
    
    }
    //  End Funtion  //
    
    //  This function ensures first banner is displayted without a delay  //
    function  QuickStart()
    {
    QuickStartID=setInterval("ImageChange()", 1000);
    }
    //  End Funtion  //                  
    
    //  This function sets display rate to user defined speed  //
    function SlowFinish()
    {
    clearInterval(QuickStartID);
    FirstLoad = 1;
    setInterval("ImageChange()", ImageDelay);  
    }
    //  End Funtion  //
    
    QuickStart()
    
    Code (markup):
    Magic Image has since come out with a randomized script and I just got that yesterday - and if you could be so kind as to let me know if there is a way that I could hook this up with buttons (so the ss can advance/go to previous) - having a hard time figuring out what the placement is for;

    
    <script type="javascript/text">
    <!-- Hide from old browsers
    function goHist(a)
    {
       history.go(a);      
    }
    // -->
    </script>
    <FORM METHOD="post">
    <INPUT TYPE="button" VALUE="  BACK " onClick="goHist(-1)">
    <INPUT TYPE="button" VALUE="FORWARD" onClick="goHist(1)">
    </form>
    
    Code (markup):
    Otherwise, I suspect that I'll have to go up a notch and start messin' with jQuery ("Easy Slider" 1.5) or that
    jClicker thing (I don't know......:lol:).

    I just caught that reference to the fact that someone loaded your server with malicious files, so I think I'm going to be going with either the Easy Slider or jClicker - for the inbuilt security measures - investigate those 2, won't you? Hope this helped you.
     
    Last edited: Oct 24, 2009
    TKY_Publishing, Oct 24, 2009 IP
  7. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #7
    it's none of my business but this question is an year and a half old, i am sure your help is appreciated nonetheless :D
     
    dimitar christoff, Oct 25, 2009 IP
  8. locals

    locals Well-Known Member

    Messages:
    1,677
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    153
    #8
    it actually was VERY MUCH appreciated !

    also mods go around and give out infractions for things like that, but it still helped me because in a year and a half NO ONE ELSE ANSWERED IT LOL

    see you guys later.
     
    locals, Oct 25, 2009 IP