title: JavaScript: Count Total # of button clicks from Multiple buttons?
body: <p>I'm trying to make the background change images based on the number of clicks I need (I know the code is not great since I have to state for every picture, but I only need 4 images because only 3 total button clicks from any of the 3 buttons are needed). Basically, I have a set of 3 buttons, and what I would like my code to do is to change background images based on the <strong>total</strong> amount of clicks from all three. Please suggest jQuery if you wish, but I don't want to use jQuery because I'd rather get used to JavaScript first. The JavaScript function doesn't seem to count anything, and it did work for only one button. Thanks! :)</p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;body&gt;
  
      &lt;script language="JavaScript" type="text/javascript"&gt; 
  
      var noOfInputs = 0;
      function buttons_click () {
  
          noOfInputs++;
  
          if(noOfInputs === "0") {
              window.document.getElementById('myImage').src="Number0.jpg";
          }
  
          if(noOfInputs === "1") {
              window.document.getElementById('myImage').src="Number1.jpg";
          }
  
          if(noOfInputs === "2") {
              window.document.getElementById('myImage').src="Number2.jpg";
          }
  
          if(noOfInputs === "3") {
              window.document.getElementById('myImage').src="Number3.jpg";
          }
  
      }
  
      &lt;/script&gt;
  
      &lt;button&gt;1&lt;/button&gt;
      &lt;button&gt;2&lt;/button&gt;
      &lt;button&gt;3&lt;/button&gt;
  
      &lt;img id="myImage" src="Number0.jpg" style="width:400px"&gt;
  
      &lt;button onclick="document.getElementById('myImage').src='Number0.jpg'"&gt;Cancel&lt;/button&gt;
  
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>Please go easy on me...I'm very prone to beginner mistakes (cause I'm a beginner). All help is greatly appreciated :)</p>