PDA

View Full Version : Randomizing ProHTML ticker



bigboy
06-17-2005, 02:58 PM
ProHTML ticker
http://www.dynamicdrive.com/dynamicindex2/prohtmlticker.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

bigboy
06-18-2005, 02:34 AM
This little script has so much potential if it could be randomized. Does anyone have any idea even where to start?

jscheuer1
06-18-2005, 03:30 AM
Try changing this function:
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:
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:
function random(n) {
return Math.floor((Math.random() % 1) * n);
}Taken loosely from this thread:

http://www.dynamicdrive.com/forums/showthread.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'.

bigboy
06-20-2005, 05:01 PM
Thanks, I searched and read through, but I must have missed this. I really appreciate the help. Thank you very much. :)