Jump to content

dane

Members
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About dane

  • Rank
    Newbie
  1. Here is my code to create the buttons <?php foreach($array as $x){ if($x !== "0"){ echo('<button class="tablink" onclick="openEvent(event,'. $x . ')">'. "Event ". $x .'</button>'); } } ?> and here is my code to open the tab <script> function openEvent(e, et) { // Declare all variables var i, tabcontent, tablinks; // Get all elements with class="tabcontent" and hide them tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } // Get all elements with class="tablinks" and remove the class "active" tablinks = document.getElementsByClassName("tablink"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } // Show the current tab, and add an "active" class to the button that opened the tab document.getElementById(et).style.display = "block"; e.currentTarget.className += " active"; } </script> as I was saying if I inspect the page it will turn all the divs to none and it will also change the active to the correct button but not turn the one I want to block and for some of the pages it works for all the tabs and then for others it doesn't
  2. Hello I am having some difficulties with my javascript tabs. I used this tutorial to set up my tabs. https://www.w3schools.com/howto/howto_js_tabs.asp For the most part it works but I have a couple of pages that use it with me creating a dynamic amount of tabs. It will works probably 98% of the time. But for some reason some of the tabs will not change the display to block. The div tab with the information is there if I go inspect the page and manually change the display to block. Can anyone help me figure out why this is happening. Thanks
×
×
  • Create New...