Jump to content

setTimeouts not working


ctoz

Recommended Posts

Back again:Sorry, but function below isn't working. I've double-checked the array items; script is in the head of the html file; have tried several combinations of backslash with single and double quotes; tried [current] inside boxDC()... stumped but hopeful.<script language="JavaScript" type="text/javascript">function boxDC (display,color,current) {oneWhite = new Array("h01","h03","h05","h09");box = document.getElementById(oneWhite[current]);box.style.display = display;box.style.color = color;if (current != oneWhite.length - 1) {current++;setTimeout("boxDC('" + display + "','" + color + "'," + [current] + ")",60);}}</script>called with<a href="#" onclick="boxDC("block","white",0); return false">test</a>

Link to comment
Share on other sites

The problem is not in the function, which works, however the way you are calling it will not work as you have quotation marks in your onclick value (onclick="boxDC("block","white",0); return false") which causes the browser to try to run onclick="boxDC(". Replace it with

<a href="#" onclick="boxDC('block','white',0); return false">test</a>

Oh, and remove the square brackets ( [ ) around "current". They will cause the function to fail.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...