Results 1 to 4 of 4

Thread: Randomizing ProHTML ticker

  1. #1
    Join Date
    Jun 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Randomizing ProHTML ticker

    ProHTML ticker
    http://www.dynamicdrive.com/dynamici...htmlticker.htm

    Is there anyway to randomize the html blocks instead of them showing up in numerical order?

    By the way, this is the coolest little script I have seen in a long time. I used it on my site if you'd like an example of how you can use it:

    http://www.sewforless.com

  2. #2
    Join Date
    Jun 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This little script has so much potential if it could be randomized. Does anyone have any idea even where to start?

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Try changing this function:
    Code:
    function expandone(){
    var selectedDivObj=document.getElementById("dropmsg"+selectedDiv)
    contractall()
    document.getElementById("dropcontentsubject").innerHTML=selectedDivObj.getAttribute("subject")
    selectedDivObj.style.display="block"
    selectedDiv=(selectedDiv<totalDivs-1)? selectedDiv+1 : 0
    setTimeout("expandone()",tickspeed)
    }
    to:
    Code:
    function expandone(){
    var selectedDivObj=document.getElementById("dropmsg"+selectedDiv)
    contractall()
    document.getElementById("dropcontentsubject").innerHTML=selectedDivObj.getAttribute("subject")
    selectedDivObj.style.display="block"
    var tempDiv=selectedDiv
    while (tempDiv==selectedDiv)
    selectedDiv=random(totalDivs)
    setTimeout("expandone()",tickspeed)
    }
    and adding this just after it in the code:
    Code:
    function random(n) {
      return Math.floor((Math.random() % 1) * n);
    }
    Taken loosely from this thread:

    http://www.dynamicdrive.com/forums/s...ead.php?t=2564

    especially message #6

    But, be aware that random means random. I've eliminated the possibility of the same message displaying repeatedly (as would be possible in a truly random scheme) but, it is still possible to alternate repeatedly between two messages. The more messages, the less likely this is to happen but, it will happen - that's random for ya'.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Jun 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks, I searched and read through, but I must have missed this. I really appreciate the help. Thank you very much.

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
  •