View Full Version : How to add Random to the scroller
Ponder
03-05-2014, 06:16 PM
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
ddadmin
03-06-2014, 02:04 AM
Try changing the line:
this.content=content
to:
this.content=content.sort(function() {return 0.5 - Math.random()}) //message array content
which will automatically randomize the order of the messages when shown.
Ponder
03-06-2014, 02:41 PM
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
ddadmin
03-06-2014, 11:56 PM
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?
Ponder
03-07-2014, 04:02 AM
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
vwphillips
03-08-2014, 04:20 PM
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
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.