I am having a hard time passing variables into functions. It works fine if I pass an integer but when I try and pass a variable it gives me an error. What am I doing wrong? When function newstimer(cur) tries to pass cur into the function change(cur) it "cur is undefined."
Code:
function newstimer(cur)
{
cur+=1;
var t=setTimeout("change(cur);",2000);
}
function change(cur)
{
document.getElementById('mainNews').style.backgroundImage="url("+mainIMG[cur]+")";
document.getElementById('mainTitle').innerHTML = bigTitle[cur];
document.getElementById('mainTitleSmall').innerHTML = smallTitle[cur];
clearTimeout(t);
newstimer(cur);
}
__________________
DVD Movie Release Database: Please login or register to view this content. Registration is FREE
|