How to create a file download page that show countdown before downloading a file. (like https://ihax.io/mx-player-tegra2-codec-zip/) when click on download button below it redirect to a page (/download-is-starting) and after a countdown over file is automatically downloaded.
On post page it uses -
<form method="post" action="https://ihax.io/download-is-starting/" class="wp-block-imple-download-file-button"><input type="hidden" name="time" value="20"><input type="hidden" name="url" value="https://driverdroidstorage.b-cdn.net/MX/mx_tegra2.zip"><button>Download mx_tegra2.zip</button></form>
and on download page (https://ihax.io/download-is-starting/) it shows javascript code like
<script type="text/javascript">
var timeleft = 20;
var downloadTimer = setInterval( function() {
if( timeleft < 0 ) {
clearInterval(downloadTimer);
const link = document.createElement('a');
link.href = 'https://driverdroidstorage.b-cdn.net/MX/mx_tegra2.zip';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
// Set the success message.
document.getElementById("download-message").innerHTML = 'Your download has started. ';
} else {
document.getElementById("sdf-countdown").innerHTML = timeleft;
timeleft -= 1;
}
}, 1000);
</script>
I want to insert the same function on my wordpress site but when i an unable to understand how to bring (link.href) value in javascript from form method post.
Basically when you alter form url value, it should also change javascript url value for a file.
Please check the site above, i am unable to explain, i am noob in coding.