php - Jquery submit doesn't submit form -
my form submits fine using plain old javascript
when try use jquery
doesn't
the form...
<form class="control_select" name="audit_delete_form" id="audit_delete_form" method="post" action="<?php echo $_server['php_self']; ?>"> <select id="audit_id_select" name="audit_id_select"> <option value="">please select</option> <? while($row = mysqli_fetch_assoc($result)){ echo '<option value="'.$row['auditid'].'">'.$row['auditname'].'</option>';}?> </select> <input type="submit" name="audit_delete_submit" id="audit_delete_submit" value="" /> </form>
the php..
if(isset($_post['audit_delete_submit'])){ $audit_id = $_post['audit_id_select']; $sql = "update audit set auditcomplete = 1, deleted = 1 auditid = '$audit_id'"; $result2 = mysqli_query($mysqli,$sql) or die(mysqli_error($mysqli)); }
the jquery...
$(document).ready(function(){ $("#audit_delete_submit").click(function(e){ e.preventdefault(); var x=document.forms["audit_delete_form"]["audit_id_select"].value; if(x==null || x=="") { $.msgbox("please select audit", { type:"alert", buttons: [ {type: "submit", value: "ok"} ] }); }else{ $.msgbox("are sure want permanently delete audit?", { type: "confirm", buttons : [ {type: "submit", value: "yes"}, {type: "submit", value: "no"}, {type: "cancel", value: "cancel"} ] }, function(result){ if(result == "yes"){ alert(result); $("form#audit_delete_form").submit() } }); } }); });
all of jquery
works except actual submit including alert(result)
shows correct value
it weird trick, if add return false
end of function, submit should work. i've been there, fixed :)
} return false; }); });
Comments
Post a Comment