PDA

View Full Version : Marquee question



JRaskal
01-10-2005, 04:47 PM
This is a bit of a combined question between ASP and the following script. I am using this marquee script...

http://dynamicdrive.com/dynamicindex2/cmarquee.htm

...to scroll a random message across our web pages. I have a database table with the messages and on each page load I get a random message out of the table and feed it to this script. All that works fine. I want to now change it so the when the message completes its pass across the page, I want the message to change to another random message. Does anyone know of a script like that, or can suggest how to go about making this change?
Thank you.

sulla
01-10-2005, 11:36 PM
here just a quick solution, that is probably not all that good, but it works.

before calling your script retrieve all your random messages from the db at once. the script will display each one at a time until all messages have been displayed and then repeat.

then modify the marquee script as follows:

where $text is your array of messages...

//var marqueecontent='<nobr>".$text."</nobr>'
var marqueecontent = new Array();
marqueecontent[0]='<nobr>".$text[0]."</nobr>'
marqueecontent[1]='<nobr>".$text[1]."</nobr>'
marqueecontent[2]='<nobr>".$text[2]."</nobr>'
marqueecontent[3]='<nobr>".$text[3]."</nobr>'
var current = 0; //pointer to current message

...

whereever you see the word 'marqueecontent' replace with 'marqueecontent[current]'

...

in function scrollmarquee()
if (iedom) {
if(parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8)){
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+\"px\"
}else{
cross_marquee.style.left=parseInt(marqueewidth)+8+\"px\"
current++;// increment current
if (current > marqueecontent.length-1) current = 0;//reached end of list of messages
//populate again
if (iedom){
cross_marquee.innerHTML=marqueecontent[current]
}else if (document.layers) {
ns_marquee.document.write(marqueecontent[current])
ns_marquee.document.close()
}
}
else if (document.layers) {
//do the same adjustmets here.
}