PHP全选 删除

 (js 代码)

function del(c){

  if(c.checked){

    c.parentNode.parentNode.bgColor = 'green';

  } else {

    c.parentNode.parentNode.bgColor = 'white';

  }

}

function e(t){

    var es = document.form2.elements;

    for(var i=0;i<es.length;i++){

  if(es[i].type == 'checkbox' ){

  if(t == 'a'){

  es[i].checked = true; del(es[i]);

}

if(t == 'o'){

  es[i].checked = !es[i].checked; del(es[i]);

  }

}

}

}

 

(html  代码)

<form name="form2" method="post" action="index.php?module=RProduct&action=delall" >

   <th>选</th>

   <td><input type="checkbox" name="oneids[]" value="{$item->id}" οnclick="del(this);"/></td>

<tr height="40" bgColor="white" ><td valign="middle">

  <a href="javascript:e('a');">全选</a> | <a href="javascript:e('o');">反选</a>

  <input type="hidden" name="delname" id="delname" value="{$page}">

  <input type="submit" class="scbtn" name="bchdel" value="删除" οnclick="return confirm('确定要删除吗?');"/>

</td></tr>

</form>

 

(php 代码)

 

$oneids = $request->getParameter("oneids");

$delname = $request->getParameter("delname");

if($oneids != ''){

$ids_str = implode(',',$oneids);

$sql = "delete from ntc_rproducts where id in($ids_str)";

$r = $db->update($sql);

  if ($r){

    删除成功

    }else{

    删除失败

}

 

转载于:https://www.cnblogs.com/nonoleng/p/5072294.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值