Some help please..

Some help please..

So I have an "Image Approval" page that I'm attempting to use jQuery on to submit the forms. I am running into issues because there are multiple forms on the same page as well as two different submit options - one for "Approve" and one for "Delete".

I tried setting each button to its own function approve() and delete() but the problem I am having is being able to pull variables out of the specific form that was submitted. I've tried doing something like this:

  1. function approve() {
  2.     var name = $(this).parent("form").attr("name");
  3.     alert(name);
  4. }


On the "Approve" button but for some reason all I can get it to alert is "undefined" - no matter what combination of parent, parents, prev, input, hidden, input:first, etc etc. Basically my form is laid out like this:

  1. <form method="post" name="'.$name.'" id="'.$name.'" onSubmit="return false;">
  2. <a href="'.$image.'" target="_new"><img src="t.php?src='.$image.'&w=125&zc=2" border="0"></a>
  3. <br>'.$name.'
  4. <input type="hidden" name="image" value="'.$image.'">
  5. <input type="hidden" name="name" value="'.$name.'">
  6. <input type="submit" value="approve" id="approve" name="approve" onClick="approve()">
  7. <input type="submit" value="delete" id="delete" name="delete" onClick="delete()">
  8. </form>

I need to pass the two hidden inputs to my ajax POST  - but since there are at least 5 of these forms (with unique identifiers) I am having tons of trouble. If someone can give me a (probably very simple) solution to this I'll forever be in your debt and PayPal you some cash for your time probably.

I know you guys get a lot of "newbs" here and probably get tired of hearing the same requests over and over - but believe me I've searched over and over for at least 2 weeks know and just don't get it.

Oh and if it helps, my ajax submit looks like this - I didn't include it because I'm just trying to break it down to the basics in order to get individual variables from multiple forms and submit buttons.

  1. function approve(){
  2.     showLoader();
  3.     $.ajax({
  4.         type: "POST",
  5.         url: "process.php",
  6.         data: "image=" + image + "&action=approve",
  7.         success: function(html) {
  8.             hideLoader();
  9.             $("#result").html(html);
  10.             $("td" + name).slideUp(300,function()  {
  11.                   $("td" + name).remove();
  12.             });
  13.         }
  14.     });
  15. }