I have been scripting in javascript for quite a while now, though I have come across a problem and I wonder if anyone knows what I am doing wrong.I have a function that is called by a setTimeout line, within the original function, i.e. an infinite loop, though has a condition to stop the function once it has finished what it should do.This function has an argument to it, just a number, that edits the right <div>'s from an array of id's. When I set an argument in the function in the timeout it fails.
function myFunction(functionVar){some code using the variable in the function argument;t = setTimeout('myFunction(functionVar);',2);}
When I set a global variable and leave out the argument the loop runs fine, though I want multiple instances of the function to run, depending upon the user input, and when I try this the functions interfere with each other as they all run from the same global variable.Basically, have I a syntax error in my timeout statement or is what I am trying to impossible thought javascript?