• 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 to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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 2 years, 4 months ago by Davesjoshin.
    Thread Starter zeesteve

    (@zeesteve)

    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.