I found this script:
<script language="Javascript" TYPE="text/javascript">
var container = document.getElementById('dl');
var seconds = 10;
var timer;
function countdown() {
seconds--;
if(seconds > 0) {
container.innerHTML = 'Please wait <b>'+seconds+'</b> seconds..';
} else {
container.innerHTML = '<a href="download.php">Download</a>';
clearInterval(timer);
}
}
timer = setInterval(countdown, 1000);
</script>
and I’m trying to call it with:
<input type="button" onclick="countdown()" id="dl" value="Download" />
but nothing happens. What am I doing wrong? I have JavasScript enabled but nothing happens after I click the button.
The script is starting itself with the setInterval function call, and is assigning the countdown to the element with the innerHTML property.
If you want to show that in the button, you should use the value property of the element and change the behaviour (i.e.: the link will not work there) or use a span or div element instead the button.