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:
- function approve() {
- var name = $(this).parent("form").attr("name");
- alert(name);
- }
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:
- <form method="post" name="'.$name.'" id="'.$name.'" onSubmit="return false;">
- <a href="'.$image.'" target="_new"><img src="t.php?src='.$image.'&w=125&zc=2" border="0"></a>
- <br>'.$name.'
- <input type="hidden" name="image" value="'.$image.'">
- <input type="hidden" name="name" value="'.$name.'">
- <input type="submit" value="approve" id="approve" name="approve" onClick="approve()">
- <input type="submit" value="delete" id="delete" name="delete" onClick="delete()">
- </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.
- function approve(){
- showLoader();
- $.ajax({
- type: "POST",
- url: "process.php",
- data: "image=" + image + "&action=approve",
- success: function(html) {
- hideLoader();
- $("#result").html(html);
- $("td" + name).slideUp(300,function() {
- $("td" + name).remove();
- });
- }
- });
- }