title: How to validate different input submit buttons in one form using javascript
body: <p>I am trying to make the below code only display the "Are you sure you want to proceed deleting the selected?" javascript message only when I click on the delete input button my my form. Can someone please help me? The other input buttons I just want to display "You do not have any selected files."</p>
  
  <p>My checkbox[] is an array and those values are being generated through mysql/php.</p>
  
  <pre><code>  &lt;script type = "text/javascript"&gt;
    function confirm_update() {
    var chkCount = 0;
    var arrCheckboxes = document.formtop.elements["checkbox[]"];
    for (var i=0; i&lt;arrCheckboxes.length; i++) {
      if(arrCheckboxes[i].checked == true) {
          chkCount++;
      }
    }
      if (chkCount === 0) {
      alert("You do not have any selected files.");
      return false;
     } else {
        return confirm("Are you sure you want to proceed deleting the selected?");
    }
   }
  
   &lt;/script&gt;
  
  
  
  
  
  
    &lt;form   name="formtop"  onsubmit="return confirm_update();"  method="POST" action=""    &gt;
  
  &lt;table border="0" cellspacing="0" cellpadding="4" bgcolor="#FFFFFF" id="Text_Buttons" &gt;
   &lt;tr&gt;
  &lt;td align="center"&gt;&lt;input id="content-button" style="width:90px;" type="Button"    name="Preferences_button" value="Edit Ad" &gt;&lt;/td&gt;     
  &lt;td align="center"&gt;&lt;input id="content-button" style="width:90px;" type="submit" name="delete" value="Delete Ad" &gt;&lt;/td&gt;
   &lt;td align="center"&gt;&lt;input id="content-button" style="width:90px;" type="submit" name="pause" value="Pause" &gt;&lt;/td&gt;
  &lt;td align="center"&gt;&lt;input id="content-button" style="width:90px;" type="submit" name="resume" value="Resume" &gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;/table&gt;
  
  
  
   &lt;input type="checkbox" name="checkbox[]" value="1" /&gt;
  
  &lt;/form&gt;
  </code></pre>