PDA

View Full Version : Randomize the XML ticker



Azteccoupe
11-22-2010, 06:34 PM
1) Script Title: Ajax XML Ticker (txt file source)

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

3) Describe problem: I am using the ticker to show short testimonials on various site pages, but I would like the messages to be random - so the same first entry does not show up on every page.

ddadmin
11-22-2010, 07:53 PM
To randomize the order of the messages when they are shown, try finding the below block of code inside the .js file, and add to it the line in red:


//Cycle through XML object and store each message inside array
for (var i=0; i<this.contentdiv.getElementsByTagName("div").length; i++){
if (this.contentdiv.getElementsByTagName("div")[i].className=="message")
this.messages[this.messages.length]=this.contentdiv.getElementsByTagName("div")[i].innerHTML
}
this.messages.sort(function() {return 0.5 - Math.random()})