Private_Guy
07-02-2007, 01:21 AM
Hi there all,
I have this following code which is on a timer, here it is:
<script type="text/javascript">
for(var i=0;i<20;i++)
setTimeout("foo('"+i+"')",(20-i)*2000);
function foo(n){
document.getElementById('btn').value=n;
if(n==0){
document.getElementById('btn').value='Download Now!';
document.getElementById('btn').disabled=false;
}
} </script>
Which I have tried to replace the "20 seconds with a php string called "<?=TIME_LIMIT?> which equals to 20, this is what I did:
<script type="text/javascript">
for(var i=0;i<<?=TIME_LIMIT?>;i++)
setTimeout("foo('"+i+"')",(<?=TIME_LIMIT?>-i)*<?=TIME_LIMIT?>00);
function foo(n){
document.getElementById('btn').value=n;
if(n==0){
document.getElementById('btn').value='Download Now!';
document.getElementById('btn').disabled=false;
}
} </script>
But it didn't work :(. Howcome? Is it because you cant use PHP Strings in JavaScripts? Thanks very much for your help and support :)
Best Regards,
Private_Guy
I have this following code which is on a timer, here it is:
<script type="text/javascript">
for(var i=0;i<20;i++)
setTimeout("foo('"+i+"')",(20-i)*2000);
function foo(n){
document.getElementById('btn').value=n;
if(n==0){
document.getElementById('btn').value='Download Now!';
document.getElementById('btn').disabled=false;
}
} </script>
Which I have tried to replace the "20 seconds with a php string called "<?=TIME_LIMIT?> which equals to 20, this is what I did:
<script type="text/javascript">
for(var i=0;i<<?=TIME_LIMIT?>;i++)
setTimeout("foo('"+i+"')",(<?=TIME_LIMIT?>-i)*<?=TIME_LIMIT?>00);
function foo(n){
document.getElementById('btn').value=n;
if(n==0){
document.getElementById('btn').value='Download Now!';
document.getElementById('btn').disabled=false;
}
} </script>
But it didn't work :(. Howcome? Is it because you cant use PHP Strings in JavaScripts? Thanks very much for your help and support :)
Best Regards,
Private_Guy