Results 1 to 2 of 2

Thread: Randomize the XML ticker

  1. #1
    Join Date
    Jan 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Randomize the XML ticker

    1) Script Title: Ajax XML Ticker (txt file source)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...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.

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

    Default

    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:

    Code:
    		//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()})
    DD Admin

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
  •