Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Banned
    Join Date
    Mar 2003
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    interval along with span + a repeat :)

    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

  • #2
    Regular Coder
    Join Date
    Mar 2003
    Posts
    176
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try this for a lark:
    Code:
    <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>
    Last edited by HairyTeeth; 04-12-2003 at 01:51 PM.

  • #3
    Banned
    Join Date
    Mar 2003
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts
    any reason for the ending on "thearray" to be on the next line?

    also, what is "foo"?

    thanks, I will use that


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •