引用js实现checkbox批量选中

<!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>
  <title>checkbox全选</title>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  <style type="text/css"></style>
  <script type="text/javascript"></script>
 </head>
 <body>
   <table  style="border:1px solid red;">                               
                    <tr>
                        <th style="background-color:#f7f7f7;width:8%;text-align:center;" class="lf">
                            <input name='chkAll' type='checkbox' id='chkAll'  onClick="checkAll(this, 'id[]')" value='checkbox' />&nbsp;全选
                        </th>
                        <th style="background-color:#f7f7f7;width:8%;" class="lf">商品编号</th>
                        <th style="background-color:#f7f7f7;width:13%;" class="lf">名称</th>
                        <th style="background-color:#f7f7f7;width:18%;" class="lf">标题</th>            
                        <th style="background-color:#f7f7f7;width:8%;" class="lf">品牌</th>
                        <th style="background-color:#f7f7f7;width:8%;" class="lf">组别</th>        
                    </tr>
                    <tr>
                        <td class="lf" style="text-align:center;">
                        <input name='id[]' type='checkbox' value='{id}'  onClick="checkItem(this, 'chkAll')">
                        </td>
                        <td class="lf">001</td>
                        <td class="lf">002</td>
                        <td class="lf">003</td>
                        <td class="lf">004</td>
                        <td class="lf">005</td>         
                    </tr>   
                          <tr>
                        <td class="lf" style="text-align:center;">
                        <input name='id[]' type='checkbox' value='{id}'  onClick="checkItem(this, 'chkAll')">
                        </td>
                        <td class="lf">001</td>
                        <td class="lf">002</td>
                        <td class="lf">003</td>
                        <td class="lf">004</td>
                        <td class="lf">005</td>         
                    </tr> 
                    <tr height="45">
                        <td colspan="10" style="text-align:left;padding-left:40px;">
                            <input type="button" id="btn_show" value="批量展示" style="width:100px;margin-left:20px;">
                        </td>                
                    </tr>
                </table>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="checkbox.js"></script>
<script type="text/javascript">
 /*var ids = [];
    $('#btn_show').click(function(){
        btnCheck('展示');
         data = {
            "ids":ids
        };
        $.ajax({
            type:"POST",
            url:"{:U('Mall/GoodsShow')}",
            data:data,
            //dataType:"json",
            success:function(msg){
                if(msg == 00){
                    alert("批量展示成功");
                    window.location.href='/index.php/Admin/Mall/MallList';
                }else{
                    alert("批量展示失败,请重新编辑");
                }
            },
            error:function(){
                  alert("批量编辑失败,请重新编辑");
             }
        });                  
    });
      function btnCheck(info){
        var obj = $("input[name='id[]']:checked").each(function(){
            ids.push($(this).val());
        });
        if (ids == false) {
            alert("请选定要" info "的商品");
            return false;
        }else {
            return ids; 
        }
    }
*/
</script> </body> </html>

 


更多专业前端知识,请上 【猿2048】www.mk2048.com
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值