在show.php页面中有如下记录
id title content
1   t1   c1
2   t2   c3
... ...  ...     
现 要对上面的记录进行批量删除,
可以选其中一条删除,也可以全删除
此页面中的删除php函数是 delDB()
这怎么实现呀,谢谢

解决方案 »

  1.   

    每条记录的都加checkBox按钮,按钮值设成ID,点多少就删除多少
      

  2.   

    楼上的,
    1 checkBox id是js代码,怎么传给php 函数用。
    2 全选怎么实现
    谢谢
      

  3.   


    // frm is the form object
    // elm is the checkbox which initiated the click
    // val is the unique group name
    function select_deselectAll (formname, elm, group)
    {
    var frm = document.forms[formname];

        // Loop through all elements
        for (i=0; i<frm.length; i++)
        {
            // Look for our Header Template's Checkbox
            if (elm.attributes['checkall'] != null && elm.attributes['checkall'].value == group)
            {
                if (frm.elements[i].attributes['checkme'] != null && frm.elements[i].attributes['checkme'].value == group)
                  frm.elements[i].checked = elm.checked;
            }
            // Work here with the Item Template's multiple checkboxes
            else if (frm.elements[i].attributes['checkme'] != null && frm.elements[i].attributes['checkme'].value == group)
            {
                // Check if any of the checkboxes are not checked, and then uncheck top select all checkbox
                if(frm.elements[i].checked == false)
                {
                    frm.elements[1].checked = false; //Uncheck main select all checkbox
                }
            }
        }
    }<input type="checkbox" checkall="group" onClick="javascript: return select_deselectAll ('deletenews', this, 'group');"> 删除</td>
      

  4.   

    把checkbox的id用js传给后台php的URL,实现效果全选用js循环,
    document.getElementById("cbid").checked = true;
    传递值到后台用post方式。
      

  5.   

    3 楼的和php 的deldb函数连起来了吗,
      

  6.   

    html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>办房后勤更新的库存物料</title>
    <link href="../config/t1.css" type="text/css"  rel="stylesheet" />
    </head>
    <script language="javascript" type="text/javascript">
    //全选
    function SelectAllCheckboxes(spanChk)
        {
            var xState=spanChk.checked;
    //alert(xState);        elm = spanChk.form.elements;
    //alert(elm.length);
            for(i = 0; i < elm.length-1; i++)
            { 
                if(elm[i].type == "checkbox" && elm[i].id != spanChk.id)
                {

                    if(elm[i].checked!=xState)
                    elm[i].click(); 
                }

            }
         }
    </script>
    <body>
    <form id="form1" name="form1" method="post" action="">
    <input name="allselect" type="checkbox"  id="allselect"  onclick="SelectAllCheckboxes(allselect)" />全选<input type="submit" name="sbt" value="提交" id="cancel" onclick="fsubmit(this.id)"/>
    </form>
    </body>
    </html>
      

  7.   

    每一列都有一个 checkbox
    <input type="checkbox" name="ids[]" value="<?php echo $row['id']; ?>" checkme="group"/>
    放到form里面,提交处理
    $ids=$_POST['ids'];  //可以取到id的数组,剩下就不用说了吧
      

  8.   

    1、用JS函数控制当前页checked的全选状态
    2、再用JS函数判断checked是否已选,将已选的ID连结成字串传送到PHP处理页
    3、单独删除:把ID直接传送到PHP处理页(跟2中处理页可以相同)
    4、PHP处理页中判断传来的字串分解成数组循环删除记录
      

  9.   

    <tr><td><input type="checkbox" name="chk[]" value="a">1</td></tr>
    <tr><td><input type="checkbox" name="chk[]" value="b">2</td></tr>
    <tr><td><input type="checkbox" name="chk[]" value="c">3</td></tr>
    <tr><td><input  type="button" value="全选"></td></tr>全选 怎么实现呀,谢谢大家
      

  10.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>办房后勤更新的库存物料</title>
    <link href="../config/t1.css" type="text/css"  rel="stylesheet" />
    </head>
    <script language="javascript" type="text/javascript">
    //全选
    function SelectAllCheckboxes(spanChk)
        {
            var xState=spanChk.checked;
            //alert(xState);        elm = spanChk.form.elements;
            //alert(elm.length);
            for(i = 0; i < elm.length; i++)
            { 
                if(elm[i].type == "checkbox" && elm[i].id != spanChk.id)
                {
                    
                    if(elm[i].checked!=xState)
                    elm[i].click(); 
                }
                
            }
         }
    </script>
    <body>
    <form id="form1" name="form1" method="post" action="">
    <input name="allselect" type="checkbox"  id="allselect"  onclick="all_select(allselect)" />全选<input type="submit" name="sbt" value="提交" id="cancel" onclick="fsubmit(this.id)"/>
    <input type="checkbox" name="checkbox" value="checkbox" />
    <input type="checkbox" name="checkbox2" value="checkbox" />
    <input type="checkbox" name="checkbox3" value="checkbox" />
    <input type="checkbox" name="checkbox4" value="checkbox" />
    <input type="checkbox" name="checkbox5" value="checkbox" />
    </form>
    </body>
    </html>
    借用三楼的大哥
    实现全选
      

  11.   

    p_chk=$_POST["chk"];
    echo "Count Checkbox : ".count($p_chk)." <br>";
    echo "Their values are : <br>";
    for($i=0;$i <count($p_chk);$i++)
    {
      echo $p_chk[$i]." <br>";