qiyu注:测试可用,需要注意的是var theform=document.Form1 这个“Form1”要改成实际的名字。
全选/反选js
function SelectAll() { var theform=document.Form1; if(theform.Checkbox1.checked) { for(var i=0;i < theform.elements.length;i++) { if (theform.elements[i].type == 'checkbox') { var e = theform.elements[i]; e.checked = true; } } } else { for(var i=0;i < theform.elements.length;i++) { if (theform.elements[i].type == 'checkbox') { var e = theform.elements[i]; e.checked = false; } } } }
操作按钮
<input type=checkbox id="Checkbox1" name=Checkbox1 nclick="SelectAll();"/>
选择对象
<input type=checkbox id=ckb name=ckb value=runat=server/>
遍历选中按钮
string arrid="";
string a="";
foreach (RepeaterItem item in AdminList.Items)
{
HtmlInputCheckBox chkbox1=(HtmlInputCheckBox)item.FindControl("ckb");
if (chkbox1.Checked==true)
{
arrid+=chkbox1.Value+",";
a+=chkbox1.Value;
}
}
if(a.Length==0)
{
Response.Write("<script>alert('请选择短信息');window.location.href='noteManage.aspx?g=notelist';</script>");
return;
}
arrid=arrid.Substring(0,arrid.Length-1);
string[] id=arrid.Split(',');
if(id.Length>=1)
{
for(int i=0;i<id.Length;i++)
{
DB.Note_Delete(id[i].Trim(),2);
}
Response.Write("<script>alert('短信息删除成功');window.location.href='noteManage.aspx?g=notelist';</script>");
}