acidglitter Posted March 8, 2008 Share Posted March 8, 2008 i have a function that starts out.. function confirm(trID, data){ and inside it i have setTimeout(okaythen(trID),2000); after the function ends i have function okaythen(trID){ document.getElementById('row_1_2').innerHTML = trID; } right now i'm just trying to get the <td> to show its id (trID) just to make sure it works, but it doesn't for some reason. if i change the setTimeout to setTimeout(okaythen('okay'),2000); then inside the <td> it shows 'okay', but for some reason it won't carry a variable... i spent forever trying to fix this. i also tried setTimeout("okaythen(" + trID + ")",2000); but that won't work either. does anyone know what i can do to fix this?? Quote Link to comment Share on other sites More sharing options...
nogray Posted March 11, 2008 Share Posted March 11, 2008 You'll lose the function scope in setTimeout, you can use global variables or the variable value. e.g. setTimeout("okaythen('" + trID + "')",2000); Notice the single quote ' before the " + to make the value as a string Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.