从数据库中读出的数条记录在页面上显示,怎么通过勾选每条前的复选框并通过确认键在数据库中删除这些被选中的记录!
请有能力的大哥帮忙!

解决方案 »

  1.   

    String[] arr = request.getParameterValues("id");
      

  2.   

    jsp:
    <input type="checkbox" name="checkProductId" value="<bean:write name='product' property='productid'/>"><a href="javascript:ondown(this)">全选</a>function ondown(obj)
    {    
     for (var i=0;i<document.adminProductForm.length;i++)
      {  
        var e = document.adminProductForm[i];
        var aa = e.name.substring(0,14)
        if(aa=="checkProductId")
        {    
          e.checked = true;
        }
     }
    }
    action:
    long[] checkProductId = adminProductForm.getCheckProductId();//form 定义long[] checkProductId ;
     
      if(checkProductId != null)
      {
      for(int i = 0; i<checkProductId.length ; i++)
      {
      productDAO.delete(checkProductId[i]);//删除方法;
      }
      }
    这样单独勾选几个删除或者全选删除都可以实现。