C#Repeater1全选ID 删除 处理
<div class="wrap" style="width: 579px; height: 191px">
<table width="1159"><thead>
<tr>
<th width="53">
<input type="checkbox" id="j_cbAll" />
</th>
<th>ID</th>
<th>栏目</th>
<th>标题</th>
<th width="171">时间</th>
<th width="147">作者</th>
<th>点击量</th>
<th>图片</th>
<th width="81">文件大小</th>
<th>编辑</th>
<th>预览</th>
<th>删除</th>
</tr>
</thead>
<tbody id="j_tb">
<asp:Repeater ID="Repeater1" runat="server" onitemcommand="Repeater1_ItemCommand" >
<ItemTemplate>
<tr>
<td width="53">
<input type="checkbox" name="delID" value='<%# Eval("ID").ToString() %>'/>
</td>
<td > <asp:Label ID="lieID" runat="server" Text= <%#Eval("ID") %>> </asp:Label> </td>
<td width="100"><%#Eval("子栏目") %></td>
<td width="185"><%#Eval("标题") %></td>
<td width="171"><%#Eval("时间") %></td>
<td width="147"><%#Eval("作者") %></td>
<td width="77"><%#Eval("浏览量") %></td>
<td width="139"> <img src="<%#Eval("缩略图1") %>" width="135" height="99" style="margin:0 auto;"></td>
<td width="81"><img src="../zip.jpg" width="50" height="50" style="margin:0 auto;"><%#Eval("文件大小") %></td>
<td width="121"><a href=# onclick="window.open('bianji-tuji.aspx?=<%#Eval("ID") %>','','fullscreen=yes');"> <input type="button" name="a1" class="button" value="编辑"></a></td>
<td width="120"><a href="../news.aspx?=<%#Eval("ID") %>" target="_blank"><input type="button" name="a2" class="button2" value="预览"></a></td>
<td width="149">
<a href="del.aspx?=<%#Eval("ID") %>" target="jianjie<%#Eval("ID") %>" onclick="document.getElementById('divjianjie<%#Eval("ID") %>').style.display='block'"> <input type="button" name="a2" id="list<%#Eval("ID") %>" class="button3" value="删除"></a>
<div id="divjianjie<%#Eval("ID") %>" onclick="this.style.display='none'" style="display:none;">
<iframe name="jianjie<%#Eval("ID") %>" src="" width="180" height ="50" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"></iframe>
</div>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
上面是Repeater1的代码
下面这里是全选和批量删除按钮的代码
<table width="1159">
<input id="Button1" type="button" value="全选/取消" onclick="javascript:document.getElementById('j_cbAll').click();" class="button"/>
<input id="Button2" type="button" value="批量删除" onclick="listqueren()" class="button3" />
</table>
下面是JS代码
<script>
function listqueren()
{
var str = document.getElementsByName("delID");
for (var i = 0; i < str.length; i++) {
if (str[i].checked==true) {
document.getElementById("list" + str[i].value).click();
}
}
}
</script>
上面这个JS是 选中的ID进行 点击按钮操作
<script>
var all = document.getElementById("j_cbAll");
var tbody = document.getElementById("j_tb");
var checkboxs = tbody.getElementsByTagName("input");
all.onclick = function () {
for (var i = 0; i < checkboxs.length; i++) {
var checkbox = checkboxs[i];
checkbox.checked = this.checked;
}
};
for (var i = 0; i < checkboxs.length; i++) {
checkboxs[i].onclick = function () {
var isCheckedAll = true;
for (var i = 0; i < checkboxs.length; i++) {
if (!checkboxs[i].checked) {
isCheckedAll = false;
break;
}
}
all.checked = isCheckedAll;
};
}
</script>
这个JS是全选按钮的