...

View Full Version : interval along with span + a repeat :)



mattover-matter
04-12-2003, 05:56 AM
Hi, How can I make a function that loops through a certain number of times and changes a color from an array?

var color[1] = "00ff00"
var color[2] = "0000ff"
etc.

then like

function changecolor(){
for (i=0;i++;color.length;){
spanname.style.color=color[i]
}
}

set interval(changecolor, 2000)

or whatknot.

Thanks all

HairyTeeth
04-12-2003, 08:15 AM
try this for a lark:



<html>
<head>
<title>Untitled</title>
<style type="text/css">
<!--
#box {
position:absolute;
visibility:visible;
top:50px;
left:300px;
width:100px;
height:50px;
border:solid 1px #EEEEEE;
color:#FFFFFF;
}
-->
</style>
<script type="text/jav&#97;script" language="jav&#97;script">
<!--;
var theArray = new Array('006600','339933','ff0044','994466','6611ff')
var i = 0;
function foo(){
i++
if(i == theArray.length) i = 0;
document.getElementById('box').style.backgroundColor=theArray[i];
setTimeout("foo()",500);
}
//-->
</script>
</head>
<body>
<a href="jav&#97script: foo()">Set It Off!!</a>
<div id="box" style="text-align:center;">
WOW!
</div>
</body>
</html>

mattover-matter
04-12-2003, 04:50 PM
any reason for the ending on "thearray" to be on the next line?

also, what is "foo"?

thanks, I will use that



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum