PDA

View Full Version : My Code Doesnt Work With MooTools !



Milad-Ab
03-01-2013, 06:12 PM
Hi,
When i add mootools.js between my codes, this timer code doesnt work correctly. help me please !



<span id='1'>02:00:58</span>


<script type='text/javascript'>
var id=new Array(50);
timer('1', 'index.php?tag=js');
</script>


function timer(data, lnk)
{
dat=document.getElementById(data);
var time=(dat.innerHTML).split(":"); var done=0;
if (time[2]>0) time[2]--;
else
{
time[2]=59;
if (time[1]>0) time[1]--;
else
{
time[1]=59;
if (time[0]>0) time[0]--;
else { clearTimeout(id[data]); window.location.href=lnk; done=1;}
}
}
if (!done)
{
dat.innerHTML=time[0]+":"+time[1]+":"+time[2];
id[data]=setTimeout("timer('"+data+"', '"+lnk+"')", 1000);
}
}

Beverleyh
03-01-2013, 07:04 PM
Where do you mean exactly when you say "between my codes"?

Is the code you've posted everything, or have you combined a few code fragments and stripped out the rest? I ask because the opening and closing script tags are missing from around your JavaScript function.

Another observation - its possible that the script isn't working because you've used a number in the id - an id should start with a letter (a-z).

That's all I've got at the moment but if you post a link to your page, hopefully somebody will be able to offer further suggestions.