title: jquery which form was
body: <p>I am adding ajax to this little list web app I made.</p>
  
  <p>I have buttons being output by a php script for each item of a list. I want to call ajax to delete an item with php and mysql when the delete button is clicked for one of the items. </p>
  
  <p>Below is the delete button for item 62. It has a hidden field which contains the id of the list item in the database. When the button is clicked I want a jquery click event to be called which should send off an ajax request to delete the item with that id from the database.</p>
  
  <pre><code>&lt;form class="actions" action="index.php" method="POST"&gt;
  &lt;input type="hidden" name="idDel" id="62" value="62"&gt;
  &lt;input type="submit" class="button delete" value="X"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The jquery I have thought of so far is below. When a button with the class .delete is clicked (any of the delete buttons) it needs to somehow get the id value from the hidden field. </p>
  
  <pre><code>('.delete').click(function(){
                //add click logic here
  
                var id = $("input.delete").val();
  
      return false;
  
      $.ajax({
        type: "POST",
        url: "delete.php",
        data: id,
        success: function() {
  </code></pre>
  
  <p>Now, I have looked at two similar questions and tried their solutions but I could not figure out the code from them. </p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/4946843/jquery-which-form-was-submitted">JQuery - which form was submitted?</a></li>
  <li><a href="https://stackoverflow.com/questions/2066162/how-can-i-get-the-button-that-caused-the-submit-from-the-form-submit-event">How can I get the button that caused the submit from the form submit event?</a></li>
  </ol>
  
  <p>Thanks. </p>