0

How can I submit a particular button by jQuery without submitting other buttons in the same form

I want to post the delete button only when I click yes in jQuery confirmation box

$(document).ready(function(){
  $( "#dialog:ui-dialog" ).dialog( "destroy" );
  $( "#dialog-confirm" ).dialog({
    resizable: false,
    height:140,
    modal: true,
    buttons: {
      "Ok": function() {
        $('#form1').submit();
        //*****************************************************************
      },
      Cancel: function() {
        $( this ).dialog( "close" );
      }
    }
  });
});

Here I want to post only delete button in php without submitting whole form

$('#form1').submit();

What is the modification needs to be done in this code?

My PHP code

 if(isset($_POST['delete_btn'])  &&  $_POST['delete_btn']=='Delete' ){
    $rid=$_POST['roleid'];
    $sql_u="SELECT * FROM `user_mst` WHERE `role_id`=".$rid;
    mysql_query($sql_u,$conn) or die("Unable to execute query :". mysql_error());
 }
4

1 回答 1

3

Replace your following code:

$('#form1').submit();

for this one:

$('#id_delete').trigger('click');

where id_delete is the id of your delete button

于 2012-09-23T17:17:24.557 回答