基于js实现checkbox批量选中操作
本文实例为大家分享了js实现checkbox批量选中的具体代码,供大家参考,具体内容如下
<html>
<head>
<title>checkbox全选</title>
<metahttp-equiv="Content-Type"content="text/html;charset=UTF-8"/>
<styletype="text/css"></style>
<scripttype="text/javascript"></script>
</head>
<body>
<tablestyle="border:1pxsolidred;">
<tr>
<thstyle="background-color:#f7f7f7;width:8%;text-align:center;"class="lf">
<inputname='chkAll'type='checkbox'id='chkAll'onClick="checkAll(this,'id[]')"value='checkbox'/> 全选
</th>
<thstyle="background-color:#f7f7f7;width:8%;"class="lf">商品编号</th>
<thstyle="background-color:#f7f7f7;width:13%;"class="lf">名称</th>
<thstyle="background-color:#f7f7f7;width:18%;"class="lf">标题</th>
<thstyle="background-color:#f7f7f7;width:8%;"class="lf">品牌</th>
<thstyle="background-color:#f7f7f7;width:8%;"class="lf">组别</th>
</tr>
<tr>
<tdclass="lf"style="text-align:center;">
<inputname='id[]'type='checkbox'value='{id}'onClick="checkItem(this,'chkAll')">
</td>
<tdclass="lf">001</td>
<tdclass="lf">002</td>
<tdclass="lf">003</td>
<tdclass="lf">004</td>
<tdclass="lf">005</td>
</tr>
<tr>
<tdclass="lf"style="text-align:center;">
<inputname='id[]'type='checkbox'value='{id}'onClick="checkItem(this,'chkAll')">
</td>
<tdclass="lf">001</td>
<tdclass="lf">002</td>
<tdclass="lf">003</td>
<tdclass="lf">004</td>
<tdclass="lf">005</td>
</tr>
<trheight="45">
<tdcolspan="10"style="text-align:left;padding-left:40px;">
<inputtype="button"id="btn_show"value="批量展示"style="width:100px;margin-left:20px;">
</td>
</tr>
</table>
<scripttype="text/javascript"src="jquery-1.7.1.min.js"></script>
<scripttype="text/javascript"src="checkbox.js"></script>
<scripttype="text/javascript">
/*varids=[];
$('#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("批量编辑失败,请重新编辑");
}
});
});
functionbtnCheck(info){
varobj=$("input[name='id[]']:checked").each(function(){
ids.push($(this).val());
});
if(ids==false){
alert("请选定要"+info+"的商品");
returnfalse;
}else{
returnids;
}
}
*/
</script>
</body>
</html>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。