Title: Using time script to select which table displays
Last modified: November 25, 2022

---

# Using time script to select which table displays

 *  [zeesteve](https://wordpress.org/support/users/zeesteve/)
 * (@zeesteve)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/using-time-script-to-select-which-table-displays/)
 * My code is intended to only show the schedule of the day. But the script portion
   fails and all tables always display.
 *     ```
       <!-- wp:table -->
       <div id="monday">
       <p class="has-text-align-center"><strong>TODAY'S SCHEDULE</strong><br>[table id=8 /]</p>
       </div>
       <div id="tuesday">
       <p class="has-text-align-center"><strong>TODAY'S SCHEDULE</strong><br>[table id=9 /]</p>
       </div>
       <div id="wednesday">
       <p class="has-text-align-center"><strong>TODAY'S SCHEDULE</strong><br>[table id=10 /]</p>
       </div>
       <div id="thursday">
       <p class="has-text-align-center"><strong>TODAY'S SCHEDULE</strong><br>[table id=11 /]</p>
       </div>
       <div id="friday">
       <p class="has-text-align-center"><strong>TODAY'S SCHEDULE</strong><br>[table id=12 /]</p>
       </div>
       <div id="saturday">
       <p class="has-text-align-center"><strong>TODAY'S SCHEDULE</strong><br>[table id=13 /]</p>
       </div>
       <div id="sunday">
       <p class="has-text-align-center"><strong>TODAY'S SCHEDULE</strong><br>[table id=14 /]</p>
       </div>
       <style>
       .content {
         padding: 0 18px;
         display: none;
         overflow: hidden;
       </style>
       <script>
       const d = new Date();
       let day = d.getUTCDay();
       switch(day) {
           case 0:
             on("sunday")
             break;
           case 1:
             on("monday")
             break;
           case 2:
             on("tuesday")
             break;
           case 3:
             on("wednesday")
             break;
           case 4:
             on("thursday")
             break;
           case 5:
             on("friday")
             break;
           case 6:
             on("saturday")
             break;
         }
       function on(id) {
          document.getElementById(id).style.display = "block"
          if(id != "monday") {document.getElementById("monday").style.display = "none"}
            else if(id != "tuesday") {document.getElementById("tuesday").style.display = "none"}
            else if(id != "wednesday") {document.getElementById("wednesday").style.display = "none"}
            else if(id != "thursday") {document.getElementById("thursday").style.display = "none"}
            else if(id != "friday") {document.getElementById("friday").style.display = "none"}
            else if(id != "saturday") {document.getElementById("saturday").style.display = "none"}
            else if(id != "sunday") {document.getElementById("sunday").style.display = "none"}
       }
       </script>
       <!-- /wp:table -->
       ```
   
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fusing-time-script-to-select-which-table-displays%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Davesjoshin](https://wordpress.org/support/users/davesjoshin/)
 * (@davesjoshin)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/using-time-script-to-select-which-table-displays/#post-16235474)
 * You are getting a JS error in your console log. It appears to be how you are 
   declaring the myTimer() function.
 * try changing `myTimer(){` to `function myTimer() {`
    -  This reply was modified 3 years, 6 months ago by [Davesjoshin](https://wordpress.org/support/users/davesjoshin/).
 *  Thread Starter [zeesteve](https://wordpress.org/support/users/zeesteve/)
 * (@zeesteve)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/using-time-script-to-select-which-table-displays/#post-16235495)
 * Thank you, fixed that, then monday was eliminated. Realized the issue after that
   was that the if statement shouldn’t have had “else if” and should just be “if”
   for each case.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Using time script to select which table displays’ is closed to new replies.

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [table](https://wordpress.org/support/topic-tag/table/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [zeesteve](https://wordpress.org/support/users/zeesteve/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/using-time-script-to-select-which-table-displays/#post-16235495)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
