11540 sujets

JavaScript, DOM et API Web HTML5

Bonjour

J'ai un tableau et je souhaite supprimer une ou plusieurs données en cochant une ou plusieurs boxe.

mon problème est que les données ne s'effacent pas. Auriez vous une solution à me proposer, peut être ai je fait une erreur. La page s'actualise.


Merci beaucoup


j'ai fait ceci

      case 'delete_all':								
       if ($_POST['selected'] != '') { 
         foreach ($_POST['selected'] as $suppliers['suppliers_id'] ) {						
          tep_db_query("delete from " . TABLE_SUPPLIERS . " where suppliers_id = '" . (int)$suppliers['suppliers_id'] ."' ");
          tep_db_query("delete from " . TABLE_SUPPLIERS_INFO . " where suppliers_id = '" . (int)$suppliers['suppliers_id'] . "'");					

          $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where suppliers_id = '" . (int)$suppliers_id . "'");
          tep_db_query("update " . TABLE_PRODUCTS . " set suppliers_id = '',
                                                          products_status = 0
                        where suppliers_id = '" . (int)$suppliers['suppliers_id'] . "'
                       ");
         }
       }							
       tep_redirect(tep_href_link(FILENAME_SUPPLIERS),'page='.$_GET['page']);
      break;	


en outre dans mon html j'ai ceci :

<script type="text/javascript">
//-----------------------------------------
// Confirm Actions (delete, uninstall)
//-----------------------------------------
$(document).ready(function(){
    // Confirm Delete
    $('#form').submit(function(){
        if ($(this).attr('action').indexOf('delete',1) != -1) {
            if (!confirm('Delete/Uninstall cannot be undone! Are you sure you want to do this?')) {
                return false;
            }
        }
    });    	
});

</script>


mon code html
  <div class="buttons"><a class="button" onclick="$('form').submit();"><span><?php echo tep_image_button('button_delete_big.gif', IMAGE_DELETE); ?></span></a></div>
  <div style="width:100%;">  
  
      <form <?php echo 'action="' . tep_href_link(FILENAME_SUPPLIERS, 'page=' . $_GET['page'] . '&action=delete_all', 'NONSSL') . '"'; ?>  method="post" enctype="multipart/form-data" id="form">
  
  
  
    <div style="width:100%;">  

          <table cellpadding="0" cellspacing="0" border="0" class="display" id="example" width="100%">
              <tr class="dataTableHeadingRow">
                <td width="40" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td>
.....
              </tr>

              <tr>
                <td>
<?php 
      if ($suppliers['selected']) { 
?>
                  <input type="checkbox" name="selected[]" value="<?php echo $suppliers['suppliers_id']; ?>" checked="checked" />
<?php 
      } else { 
?>
                  <input type="checkbox" name="selected[]" value="<?php echo $suppliers['suppliers_id']; ?>" />
<?php 
      } 
?>
                </td>
.....
           </tr>
       </table> 
    </div>
</form>
</div>

Modifié par oitsuki (23 Aug 2012 - 23:29)