# (Solved) Changing text displayed at end of countdown in timer script

**URL:** <https://www.phphelp.com/t/solved-changing-text-displayed-at-end-of-countdown-in-timer-script/34634>\
**Category:** Javascript & Ajax\
**Created:** [April 1, 2022, 4:29pm UTC](https://www.phphelp.com/t/solved-changing-text-displayed-at-end-of-countdown-in-timer-script/34634 "2022-04-01T16:29:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![foxclone](https://www.phphelp.com/user_avatar/www.phphelp.com/foxclone/32/4022_2.png) [@foxclone](https://www.phphelp.com/u/foxclone)\
**Post date:** [April 1, 2022, 4:29pm UTC](https://www.phphelp.com/t/solved-changing-text-displayed-at-end-of-countdown-in-timer-script/34634/1 "2022-04-01T16:29:10Z")

</div>

I’m using a timer script that I’d like to change the displayed text when the countdown ends but have no idea how to accomplish it. I’d appreciate any help I can get. Here’s the code I’m using:

```auto
   <p> The Update will be done in <span id="countdowntimer">20 </span> Seconds</p>
        
   <script type="text/javascript">
          var timeleft = 20;
          var downloadTimer = setInterval(function(){
          timeleft--;
          document.getElementById("countdowntimer").textContent = timeleft;
             if(timeleft <= 0)
                clearInterval(downloadTimer);
            },1000);
    </script>

```

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![foxclone](https://www.phphelp.com/user_avatar/www.phphelp.com/foxclone/32/4022_2.png) [@foxclone](https://www.phphelp.com/u/foxclone)\
**Post date:** [April 1, 2022, 7:29pm UTC](https://www.phphelp.com/t/solved-changing-text-displayed-at-end-of-countdown-in-timer-script/34634/2 "2022-04-01T19:29:38Z")

</div>

Fixed by adding second if statement like this:

```auto
<p id="test"> The Update will be done in <span id="countdowntimer">10 </span> Seconds</p>
        
          <script type="text/javascript">
                var timeleft = 10;
                var downloadTimer = setInterval(function(){
                timeleft--;
                document.getElementById("countdowntimer").textContent = timeleft;
                if(timeleft <= 0)
                   clearInterval(downloadTimer);
                if(timeleft == 0)
                   document.getElementById("test").textContent = "Update Complete";   
                },1000);
                  
            </script>
        

```
