Results 1 to 6 of 6

Thread: How to add Random to the scroller

  1. #1
    Join Date
    May 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to add Random to the scroller

    1) Script Title: Pausing up-down Scroller

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex2/crosstick.htm

    3) Describe problem: Not a problem but a request for help....I use the pausing up and down scroller and it works great....But I would like to add the ""Random"" attribute and don't know or how or where.

    Can someone take a look and advise me please..



    Many Thanks...Ponder

  2. #2
    Join Date
    Aug 2004
    Posts
    10,140
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Try changing the line:

    Code:
    this.content=content
    to:

    Code:
    this.content=content.sort(function() {return 0.5 - Math.random()}) //message array content
    which will automatically randomize the order of the messages when shown.
    DD Admin

  3. #3
    Join Date
    May 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi...I changed the content line to your code suggestion but the scroller stopped scrolling...

    Here's what the content line was when things are working correctly..just want to call different message order each time the page loads...

    this.content=pausescroller.getContent(divId) //message array content

    Can you help again....Many thanks..Ponder

    Ok I just changed the code to this

    this.content=pausescroller.getContent(divId).sort(function() {return 0.5 - Math.random()}) //message array content

    And the scroller is working and is random on each page reload.....but there may be a better way to write this code....can you advise me.....many thanks again...Ponder
    Last edited by Ponder; 03-06-2014 at 03:56 PM. Reason: discovered new info

  4. #4
    Join Date
    Aug 2004
    Posts
    10,140
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Quote Originally Posted by Ponder View Post

    Ok I just changed the code to this

    this.content=pausescroller.getContent(divId).sort(function() {return 0.5 - Math.random()}) //message array content

    And the scroller is working and is random on each page reload.....but there may be a better way to write this code....can you advise me.....many thanks again...Ponder
    I'm a little confused- so the modified code does work for you? If so whats the new problem?
    DD Admin

  5. #5
    Join Date
    May 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    No new problem....but I added your code suggestion to part of the code that was already in place and since I am a novice at this, I am wondering if the way the code looks now ...part of what was there and your new code suggestion...is ok and clean....

    thanks..Ponder

  6. #6
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    you say your code contains this line

    this.content=pausescroller.getContent(divId) //message array content
    this line does not exist in the current DD pausescroller script

    please post the code and HTML you are using
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Similar Threads

  1. Fading Scroller random?
    By VictoryCig in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 09-28-2014, 08:28 PM
  2. Slide-in Scroller, how to get messages in random sequence
    By scriptseeker in forum Dynamic Drive scripts help
    Replies: 8
    Last Post: 06-15-2010, 02:42 PM
  3. looking for php random image plus random alt from folder script
    By Marquis in forum Looking for such a script or service
    Replies: 0
    Last Post: 01-05-2009, 07:31 PM
  4. Random style sheet + Random content... Possible?
    By candied_ram in forum Looking for such a script or service
    Replies: 2
    Last Post: 01-12-2008, 01:23 AM

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
  •