/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Random Scroller Help

I have decided to make a website with a random quote scroller that my friend gave me. When I added my quotes I discovered it wont work unless there is less than 10?
Im wondering what the line is to fix this problem, can anyone help me get close/to 100 quotes in there?

[B]The Code[/B]

[code]var delay = 2000; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(255,255,255); // start color (red, green, blue)
var endcolor=new Array(0,0,0); // end color (red, green, blue)

var fcontent=new Array();
begintag=”; //set opening tag, such as font declarations
fcontent[0]=”Welcome to my website.”;
fcontent[1]=”This is the new look site, go in the forums and tell us what you think.”;
fcontent[2]=”In the time it takes you to read this 18490 staples will have been use.”;
fcontent[3]=”Proudly producing fresh nonsense since 2007.”;
fcontent[4]=”Wanna hear a joke two guys ran into a bar, ouch….”;
fcontent[5]=”There were no survivers!.”;
fcontent[6]=”Chicks dig style, too bad you have none!.”;
fcontent[7]=”Aim lower, then get the shovels…”;
(ect… i need 100 quotes…)
closetag=”;

var fwidth=’773px’; //set scroller width
var fheight=’20px’; //set scroller height

var fadelinks=1; //should links inside scroller content also fade like text? 0 for no, 1 for yes.

///No need to edit below this line/////////////////

var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=0;

//function to change content
function changecontent(){
if (index>=fcontent.length)
index=0
if (DOM2){
document.getElementById(“fscroller”).style.color=”rgb(“+startcolor[0]+”, “+startcolor[1]+”, “+startcolor[2]+”)”
document.getElementById(“fscroller”).innerHTML=begintag+fcontent[index]+closetag
if (fadelinks)
linkcolorchange(1);
colorfade(1, 15);
}
else if (ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
index++
}

function linkcolorchange(step){
var obj=document.getElementById(“fscroller”).getElementsByTagName(“A”);
if (obj.length>0){
for (i=0;i<obj.length;i++)
obj[i].style.color=getstepcolor(step);
}
}

var fadecounter;
function colorfade(step) {
if(step<=maxsteps) {
document.getElementById(“fscroller”).style.color=getstepcolor(step);
if (fadelinks)
linkcolorchange(step);
step++;
fadecounter=setTimeout(“colorfade(“+step+”)”,stepdelay);
}else{
clearTimeout(fadecounter);
document.getElementById(“fscroller”).style.color=”rgb(“+endcolor[0]+”, “+endcolor[1]+”, “+endcolor[2]+”)”;
setTimeout(“changecontent()”, delay);

}
}

function getstepcolor(step) {
var diff
var newcolor=new Array(3);
for(var i=0;i<3;i++) {
diff = (startcolor[i]-endcolor[i]);
if(diff > 0) {
newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
} else {
newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
}
}
return (“rgb(” + newcolor[0] + “, ” + newcolor[1] + “, ” + newcolor[2] + “)”);
}

if (ie4||DOM2)
document.write(‘<div id=”fscroller” style=”border:1px solid black;width:’+fwidth+’;height:’+fheight+'”></div>’);

if (window.addEventListener)
window.addEventListener(“load”, changecontent, false)
else if (window.attachEvent)
window.attachEvent(“onload”, changecontent)
else if (document.getElementById)
window.onload=changecontent[/code]

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@FangDec 20.2007 — The number is unlimited, there is something else wrong.
Copy linkTweet thisAlerts:
@boomhowzaauthorDec 21.2007 — Ok? here's what i got so far, is the something wrong in the [B]"fcontent[*]"[/B] area?

[CODE]var delay = 2000; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(255,255,255); // start color (red, green, blue)
var endcolor=new Array(0,0,0); // end color (red, green, blue)

var fcontent=new Array();
begintag=''; //set opening tag, such as font declarations
fcontent[0]="Welcome to The Urban Ninjaz website.";
fcontent[1]="This is the new look site, go in the forums and tell us what you think.";
fcontent[2]="In the time it takes you to read this 18490 staples will have been use.";
fcontent[3]="Proudly producing fresh nonsense since 2007.";
fcontent[4]="Wanna hear a joke two guys ran into a bar, ouch....";
fcontent[5]="There were no survivers!.";
fcontent[6]="Chicks dig style, too bad you have none!.";
fcontent[7]="Aim lower, then get the shovels...";
fcontent[8]="You know I would, but right now i'm in the middle of something.";
fcontent[9]="I'm not in denial???";
fcontent[10]="What did you learn from watching brave heart, "Moon Thy Enimies".";
fcontent[11]="So many cats, so few recipies.";
fcontent[12]="The last thing i want to do is hurt you... But it's still on the list.";
fcontent[13]="Your next...";
fcontent[14]="Congratulations, you have just given you name, address and number to the FBI.";
fcontent[15]="There's two theories to arguing with women. Neither one works.";
fcontent[16]="Some people are funny, they spend money they don't have to buy things they don't need to impress people they don't like...";
fcontent[17]="Sometimes I think I understand everything. Then I regain consciousness.";
fcontent[18]="It's true hard work never killed anybody, but I figure, why take the chance?";
fcontent[19]="I'm planning to retire and live off my savings. What i'll do the second day, I have no idea.";
fcontent[20]="Rehab is for quiters.";
fcontent[21]="The main reason santa is so jolly is because he knows where all the bad girls live.";
fcontent[22]="You can go a long way with a smile. You can go a lot further with a smile and a gun.";
fcontent[23]="Creativity is great, but plagiarism is faster.";
fcontent[24]="It takes a big man to cry, but it takes a bigger man to laugh at that man.";
fcontent[25]="Junk: Stuff we keep | Stuff: Junk we keep.";
fcontent[26]="It's not premarital sex unless you're planning on getting married.";
fcontent[27]="Money can't buy happiness, but it sure makes misery easier to live with.";
fcontent[28]="A pedestrian hit me and went under my car.";
fcontent[29]="You can't have everything. Where would you put it?";
fcontent[30]="Sex is not the answer. Sex is the question. Yes is the answer.";
fcontent[31]="My girlfriend told me I should be more affectionate. So I got two girlfriends.";
fcontent[32]="If you aren't going to be good, atleast be good at it.";
fcontent[33]="Friends help you move. Real friends help you move bodies.";
fcontent[34]="Men like to barbeque. Men will cook if danger is involved.";
fcontent[35]="I may not be perfect, but parts of me are excellent.";
fcontent[36]="If a cow laughs, does milk come out it's nose?";
fcontent[37]="Do they have reserved parking for non-handicapped people at the special olympics?";
fcontent[38]="Last night I played a blank tape at full blast. The mime next door went nuts.";
fcontent[39]="Marcel Marceau is currently doing the biggest performance of his life!";
fcontent[40]="If a tree falls in the forest and no one is around to see it, do the other trees make fun of it?";
fcontent[41]="1";
fcontent[42]="2";
fcontent[43]="3";
fcontent[44]="4";
fcontent[45]="5";
fcontent[46]="6";
fcontent[47]="7";
fcontent[48]="8";
fcontent[49]="9";
fcontent[50]="10";
closetag='';

var fwidth='773px'; //set scroller width
var fheight='20px'; //set scroller height

var fadelinks=1; //should links inside scroller content also fade like text? 0 for no, 1 for yes.

///No need to edit below this line/////////////////


var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=0;


//function to change content
function changecontent(){
if (index>=fcontent.length)
index=0
if (DOM2){
document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
if (fadelinks)
linkcolorchange(1);
colorfade(1, 15);
}
else if (ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
index++
}

function linkcolorchange(step){
var obj=document.getElementById("fscroller").getElementsByTagName("A");
if (obj.length>0){
for (i=0;i<obj.length;i++)
obj[i].style.color=getstepcolor(step);
}
}

var fadecounter;
function colorfade(step) {
if(step<=maxsteps) {
document.getElementById("fscroller").style.color=getstepcolor(step);
if (fadelinks)
linkcolorchange(step);
step++;
fadecounter=setTimeout("colorfade("+step+")",stepdelay);
}else{
clearTimeout(fadecounter);
document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
setTimeout("changecontent()", delay);

}

}

function getstepcolor(step) {
var diff
var newcolor=new Array(3);
for(var i=0;i<3;i++) {
diff = (startcolor[i]-endcolor[i]);
if(diff > 0) {
newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
} else {
newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
}
}
return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}

if (ie4||DOM2)
document.write('<div id="fscroller" style="border:1px solid black;width:'+fwidth+';height:'+fheight+'"></div>');

if (window.addEventListener)
window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent)
else if (document.getElementById)
window.onload=changecontent[/CODE]
Copy linkTweet thisAlerts:
@FangDec 21.2007 — Nested quotesfcontent[10]="What did you learn from watching brave heart, [COLOR="Green"]"[/COLOR]Moon Thy Enimies[COLOR="Green"]"[/COLOR].";
Copy linkTweet thisAlerts:
@boomhowzaauthorDec 21.2007 — thankyou very much, i would never have got that ?

thx ? ? ?
Copy linkTweet thisAlerts:
@LazerDec 21.2007 — Hi.

i would have done this in PHP.

Much easier!

If all you need is 100 RANDOM qts, make a PHP file with qts ONLY (asier to replace, edit...) looks like that:

<?php

$quote[1] =' number 1';

$quote[2].......

$quote[100]= '100' ;

?>

and save it as quotes.php

In your [B]main [/B]page:

<?php

$pickone = rand(1, 100);

include("quotes.php");

$text = $quote[$pickone];

?>

in the [B]body [/B]of your page add:

<marqee width=773 height=20><?php print $text;?></marqee>

This will show a diferent text each time you visit the page.
×

Success!

Help @boomhowza spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...