Check multiple buttons with same id with javascript : I'm trying to build a website where people can make a reservation, I'm using a database to collect the times and php to display it. It displays all times within 5 days, including the ones that aren't available. They are displayed as buttons, all sharing the same id. I got stuck at the last step, disabling the buttons with unavailable times. Since the only difference between these buttons is their background color (grey for unavailable and green for available) I figured I'd use a javascript function in which it checks the background colors of the boxes in a condition and then the grey ones get disabled and the green ones give a form. However: it'll only check the color of the first button and all buttons give the same result as that one. My page will always display 50 buttons, so I thought I could just use a while loop with an auto-decrement at the end, however I can't seem to find out how to check the next button, it will now only check the same button again and again. Here's a part of the php-code to show the buttons with the right color (I've take some irrelevant parts out):

    while($row = $results->fetch_assoc()){
    $color = "##8fd6a5";
    if (!empty($row['unavailable'])){
    $color = "##9b9393";
    }
    $time= new DateTime($row['time']);
    if ($time->format('H') == '08'){
    echo '<button id="myBtn" onload="disablebuttons()" class="buttonstyle" 
    style="background-color: '.$color.'">'.$time>format('m/d H:i').'</button>';
    }
This works entirely, but since all buttons have id="myBtn" when disablebuttons() executes, it only looks at the first button, following this code:

    function disablebuttons() {
    var amountButton = 50;
    while (a > 0){
    var buttondisable = document.getElementById("myBtn");
    if (buttondisable.style.backgroundColor == "rgb(155, 147, 147)"){
      document.getElementById("myBtn").disabled = true;    
      a--;}
     }
    }
I've tried to delete the variable at the end of the while loop and place the "var buttondisable = document.getElementById("myBtn");" inside the loop, however this did not work. Can somebody help please?