Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <button type="button" class="btn btn-dark" onclick="countdown()">Start! <i class="fas fa-stopwatch"></i></button>
- <script>
- function countdown() {
- $.ajax({
- type: "POST",
- url: 'countdown.php'
- }
- });
- }
- </script>
- <iframe class="mt-1 ml-1" src="countdown.php" frameBorder="0" style="width: 13rem;"></iframe>
- <?php
- echo '
- <p>Time left: </p>
- <h2 id="countdown"><span id="time">/</span></h2>
- <script>
- var time = 20;
- var tick = new Audio("../sounds/tick.wav");
- var timer = setInterval(function(){
- if (time > 0) {
- time = time - 1;
- tick.play();
- document.getElementById("countdown").innerHTML = time;
- }
- if (time == 0) {
- var audio = new Audio("../sounds/zig.wav");
- audio.play();
- }
- },1000);
- }
- </script>
- ';
- }
- ?>
Add Comment
Please, Sign In to add comment