I have this JavaScript function which counts down until you can click the download button, however i would like once its clicked for it either to disable again or start counting down again, preferably, disable.
Here is the JavaScript.
<script type="text/javascript">
x = 10;
function countdown() {
if (x > 1) {
x--;
document.getElementById("button").innerHTML = x;
r = setTimeout("countdown()",1000);
}
else {
clearTimeout(r);
document.getElementById("button").innerHTML = "Click to download";
document.getElementById("button").disabled = "";
}
}
r = setTimeout("countdown()",1000);
</script>
Here is the button,
<label><font size="5">Your download will start in: </label><a href="download.php?shortURL=<?php echo $fullfile; ?>"><button class="btn orange" id="button" disabled="disabled" onclick="window.location.reload()" >10</button></font></a>
Thanks!
I believe this is the code you need: