PDA

View Full Version : SetTimeout is giving error


ksridhar69
09-23-2002, 02:47 AM
I want to call a function with in a function. I need settimeout to the inner function. But it is giving error

function mainfunction(sub)
{

//it is doing some operations

SetTimeout("callfunction(sub)",2000)

}

But it is giving error at SetTimeout . The "sub" is passing to the mainfunction. But it is not recognizing the inner sub. IS there any error

glenngv
09-23-2002, 06:06 AM
if sub is an integer:

setTimeout("callfunction("+sub+")",2000);


if sub is a string:

setTimeout("callfunction('"+sub+"')",2000);


if sub is an object with reference to an element with id attribute:

setTimeout("callfunction(document.getElementById('"+sub.id+"'))",2000);


if sub is an object with reference to a named form element:

setTimeout("callfunction(document.forms['"+sub.form.name+"'].elements['"+sub.name+"'])",1);

ksridhar69
09-23-2002, 01:15 PM
sub is a integer it is working

Thanks