title: jqGrid How to Delete Multiple Selected rows after submitting to a Database?
body: <p>I have this solution that submits multiple row data to a new database. But I want to append to the end of this action script  to delete the selected rows. How to properly add this function at the end after data has been submitted? I added a script but it does nothing. </p>
  
  <p>Old code for button:</p>
  
  <pre><code>            jQuery("#minibutton").click( function(){
  
      var selectedrows = $("#list").jqGrid('getGridParam','selarrrow');
  if(selectedrows.length) {
  for(var i=0;i&lt;selectedrows.length; i++) {
  
  var selecteddatais = $("#list").jqGrid('getRowData',selectedrows[i]);
          var rows=JSON.stringify(selecteddatais)
          var postArray = {json:rows};
  
      $.ajax({
        type: "POST",
        url: "jsonsend.php",
     data: postArray,       
     dataType: "json",
     success: function () { jQuery("#list").jqGrid('delGridRow', id, options );
  
      } }); } } });
       });
  </code></pre>
  
  <p>Edit: My current try at solution</p>
  
  <pre><code>  $(function(){ 
    $("#list").jqGrid({
      url:'request.php',
      editurl: 'jqGridCrud.php',
      datatype: 'xml',
      mtype: 'GET',
      multiselect:true,
      multiboxonly:true,
      height: 450,
      width: 850,
  
      colNames:['id','Project', 'Assigned To','Assign Date','Check Date','Due Date','Attachments'],
      colModel :[ 
        {name:'id', index:'id', width:25}, 
        {name:'name', index:'name', width:250, align:'left',editable:true, editoptions:{
              size:60} }, 
        {name:'id_continent', index:'id_continent', width:55, align:'right',editable:true,edittype:'select', 
        editoptions:{value: "Henry:Henry; Ramon:Ramon; Paul:Paul" },mtype:'POST'  }, 
  
        {name:'lastvisit', index:'lastvisit', width:70, align:'right',formatter: 'date',srcformat:'yyyy-mm-dd',newformat: 'm-d-Y',editable:true, edittype: 'text',mtype:'POST' ,editoptions:{size:10, dataInit:function(elem){$(elem).datepicker({dateFormat:'m/d/yy'});}}} ,
  
  
        {name:'cdate', index:'cdate', width:70, align:'right',formatter: 'date',srcformat:'yyyy-mm-dd',newformat: 'm-d-Y', edittype: 'text',editable:true ,mtype:'POST' ,editoptions:{size:10, dataInit:function(elem){$(elem).datepicker({dateFormat:'m/d/yy'});}}} ,
  
        {name:'ddate', index:'ddate', width:70, align:'right',formatter: 'date',srcformat:'yyyy-mm-dd',newformat: 'm-d-Y',date:'true',editable:true, edittype: 'text',editoptions:{size:10, dataInit:function(elem){$(elem).datepicker({dateFormat:'m/d/yy'});}}} ,
  
  
        {name:'email', index:'email', width:70,align:'center',sortable:false,mtype:'POST' } 
      ],
      pager: '#pager',
  
      rowNum:20,
      rowList:[20,40,80],
      sortname: 'id',
      sortorder: 'desc',
      viewrecords: true,
      gridview: true,
      caption: 'Pending Assignments',
  
  
      ondblClickRow: function(rowid) {
  
      $(this).jqGrid('editGridRow', rowid,
                          {width:450,Height:400,recreateForm:true,closeAfterEdit:true,
                           closeOnEscape:true,reloadAfterSubmit:false, modal:true,mtype:'post'});}
  
  
              });
  
  
  
         $("#list").jqGrid("navGrid", { add: false, search: false }, {}, {}, {
      url: "jsonsend.php",
      onclickSubmit: function (options, ids) {
          var $self = $(this), selectedrows = ids.split(","), selectedData = [], i,
              l = selectedrows.length;
  
          for (i = 0; i &lt; l; i++) {
              // fill array selectedData with the data from selected rows
              selectedData.push($self.jqGrid("getRowData", selectedrows[i]));
          }
  
          // the returned data will be combined with the default data
          // posted by delGridRow
          return {
              gridData: JSON.stringify(selectedData)
          }
      }
  });
  
  
       });
  </code></pre>
  
  <p>jsonsend.PHP:</p>
  
  <pre><code>&lt;?
  
  
      $database = "newhistoricform";
      $dbpassword = "pretty";
      $dbhost = "localhost";
      $dbuser = "root";
  
  
  // connect to the MySQL database server
  $con = mysql_connect($dbhost, $dbuser, $dbpassword);
  if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
  @mysql_select_db($database,$con) or die("Error connecting to db.");
  
  
  
  
  //First decode the array
  $arr = $_POST["json"];
  $decarr = json_decode($arr, true);
  $count = count($decarr);
  
  
  for ($x=0; $x &lt; $count; $x++){
  $newrec = $decarr; 
  $id = $newrec['id']; 
  $name = $newrec['name']; 
  $id_continent = $newrec['id_continent']; 
  $email = $newrec['email']; 
  $lastvisit = $newrec['lastvisit']; 
  $cdate = $newrec['cdate']; 
  $ddate = $newrec['ddate']; 
  
  }
  
  // Create insert array
  $values[] = "('".$id."', '".$name."', '".$id_continent."', '".$lastvisit."','".$cdate."','".$ddate."','".$email."' )";  
  
  
  
  
  
  // Insert the records   
  
  $sql = "INSERT INTO finish (id, name, id_continent, lastvisit,cdate,ddate, email)
  VALUES ".implode(',', $values);
  
  $result = mysql_query($sql, $con) or die(mysql_error());  
  
  
  ?&gt;
  </code></pre>