title: How can I disable and enable other buttons in Javascript something like a radio button effect?
body: <p>We are using the following script to set the color theme on my page. When user clicks a button and it sets a class on the HTML. When the user clicks another button(s) then it sets that classname instead. This works okay.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      if (localStorage.buttonColor) {
          document.getElementsByTagName('html')[0].className = localStorage.buttonColor
      }
      function getButtonColor(buttonName) {
          localStorage.buttonColor = buttonName;
          document.getElementsByTagName('html')[0].className = buttonName
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>If there's a localstorage value for the button color then it sets the class. However we also need it to disable the button. How can we make it disable the button based on the value of the localstorage?</p>
  
  <p>Also if a user clicks on a button then we want that button to be disabled and all the others with the class "theme" to be enabled. We are looking for a javascript only solution. </p>
  
  <p>Here's the HTML:</p>
  
  <pre><code>&lt;form class="ng-pristine ng-valid"&gt;
     &lt;button class="theme" name="darkBlue" onclick="getButtonColor(this.name)"&gt;Blue&lt;/button&gt;
     &lt;button class="theme" name="black" onclick="getButtonColor(this.name)"&gt;Black&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here's one solution but it's not quite all that's needed as we have now decided to give the buttons a class name to make it easier to select them. Also this only works for getting from local storage and we still need to disable a button if a user clicks it and enable all the others.</p>
  
  <pre><code>if (localStorage.buttonColor) {
      document.getElementsByTagName('html')[0].className = localStorage.buttonColor
      var buttons = document.body.getElementsByTagName('form')[0].getElementsByTagName('button')
      for(var i =0; i &lt; buttons.length; i++)
          if(buttons[i].name == localStorage.buttonColor) button.disabled = true
  }
  </code></pre>