Results 1 to 5 of 5

Thread: Help with Pausing up-down Scroller

  1. #1
    Join Date
    Feb 2010
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Help with Pausing up-down Scroller

    Link of script is: http://www.dynamicdrive.com/dynamicindex2/crosstick.htm

    I need to make it that messages will go random, is that possible?! What need to be changed?!

  2. #2
    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

    Well, there are at least three ways to look at that. If you mean each time the page loads a random order for the messages will be set, that's easy. Do it like so (addition highlighted):

    Code:
    <script type="text/javascript">
    
    /*Example message arrays for the two demo scrollers*/
    
    var pausecontent=new Array()
    pausecontent[0]='<a href="http://www.javascriptkit.com">JavaScript Kit</a><br />Comprehensive JavaScript tutorials and over 400+ free scripts!'
    pausecontent[1]='<a href="http://www.codingforums.com">Coding Forums</a><br />Web coding and development forums.'
    pausecontent[2]='<a href="http://www.cssdrive.com" target="_new">CSS Drive</a><br />Categorized CSS gallery and examples.'
    
    pausecontent.sort(function() {return 0.5 - Math.random();});
    
    var pausecontent2=new Array()
    pausecontent2[0]='<a href="http://www. . . .
    This may be done for one or more (if you have more than one) array of contents. Simply run the randomizing command after each array declaration you want to randomize, using that array's name, as shown in the example.

    If however you want to have a random message shown each time the message changes, that's a little misleading because it would lead to duplicate messages being shown one after another at times. Random means random. Any message, including that just shown, could follow any message. A subroutine could be developed to prevent that, essentially shuffling the array after removing the current message. But you would still occasionally get the same message following soon after itself. So, as tempting in theory as it might seem, I'd advise against that approach.

    The third method would be to shuffle after each time a full cycle of messages had been shown. This could still result in duplicate messages following one after the other. Only this time, though a less likely (rarer) occurrence, I'm not sure how if at all that could be prevented. So again I wouldn't recommend it.
    - John
    ________________________

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

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    indijanac (02-21-2010)

  4. #3
    Join Date
    Feb 2010
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    yeah thats what i wanted, everytime when page is loaded to show random messages. Just one more question:

    if i add 10 pausecontent messages, i must change something in:
    pausecontent.sort(function() {return 0.5 - Math.random();});

    or not?!

  5. #4
    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

    Not. It will work for any length array.
    - John
    ________________________

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

  6. The Following User Says Thank You to jscheuer1 For This Useful Post:

    indijanac (02-21-2010)

  7. #5
    Join Date
    Feb 2010
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    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
  •