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