PDA

View Full Version : Fading Scroller Randomization



vacation home advisors
08-01-2005, 01:50 PM
I have implemented the Dynamic Drive Fading Scroller, but have no way to randomize the over 30 pieces of content displayed from it, therefore all of my returning visitors must wait through the ones they have already viewed to see new or different content. If anyone has already written an addition to this script to make the contents random, please reply.
thank you,

A. Jorett
Vacation Home Advisors, LLC
ahj[at]vacationhomeadvisors.com

jscheuer1
08-01-2005, 02:20 PM
Mike (mwinter) from these forums has already written an excellent randomizing unit that may be used with virtually any script that has an array (as this one does) to randomize its contents. It is still available for view in this post (http://www.dynamicdrive.com/forums/showthread.php?p=8442). Basically, what you would do is insert the code from that post after the array of messages and after that insert this line:

fcontent.shuffle()Thanks again for this great randomizing unit, Mike!

crazycalvinist
07-24-2006, 08:53 PM
Mike (mwinter) from these forums has already written an excellent randomizing unit that may be used with virtually any script that has an array (as this one does) to randomize its contents. It is still available for view in this post (http://www.dynamicdrive.com/forums/showthread.php?p=8442). Basically, what you would do is insert the code from that post after the array of messages and after that insert this line:

fcontent.shuffle()Thanks again for this great randomizing unit, Mike!

I tried the solution but it didn't work. After I put in the call to the function it breaks.

ddadmin
07-25-2006, 12:52 AM
Warning: Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.

Here you go, just add the code in red below directly following your array contents:


var fcontent=new Array();
begintag='<div style="font: normal 14px Arial; padding: 5px;">'; //set opening tag, such as font declarations
fcontent[0]="<b>What\'s new?</b><br>New scripts added to the Scroller category!<br><br>The MoreZone has been updated. <a href='../morezone/index.htm'>Click here to visit</a>";
fcontent[1]="Dynamic Drive has been featured on Jars as a top 5% resource, and About.com as a recommended DHTML destination.";
fcontent[2]="Ok, enough with these pointless messages. You get the idea behind this script.</a>";
closetag='</div>';

var randomizecontents="yes" //randomize dislay order of images? "yes" or "no"
function shuffleit(){
return Math.floor((Math.random()*fcontent.length-1))
}

if (randomizecontents=="yes")
fcontent.sort(shuffleit)

KraftyOne
03-12-2008, 04:28 PM
This is exactly what I needed! Thank you smart people of the world!