title: Javascript: Run a script depending on which button is clicked
body: <p>Can someone enlighten me on this please. I was trying to implement a simple Javascript function. The idea is, to run a conditional script depending on which button is clicked. Can't seem to figure this out:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  function whichButton(){
  
  if(//Button 1 is clicked...){
      //Run script 1   
   }
  else if(//Button 2 is clicked){
      //Run script 2  
   }
  else if(//Button 3 is clicked){
      //Run  script 3  
   }
  else if(//Button 4 is clicked){
      //Run script 4  
   }
  else{
      //Do nothing
   }
  }
  &lt;/script&gt;
  
  &lt;form id="form1" onSubmit="whichButton();"&gt;
  &lt;button id="btn1"&gt;Button 1&lt;/button&gt;&lt;br/&gt;
  &lt;button id="btn2"&gt;Button 2&lt;/button&gt;&lt;br/&gt;
  &lt;button id="btn3"&gt;Button 3&lt;/button&gt;&lt;br/&gt;
  &lt;button id="btn4"&gt;Button 4&lt;/button&gt;&lt;br/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Thanks in advance!</p>