ASP记录复选框全选方法
怎样添加一个全选的复选框呢,,,,记录集有循环的,,,<%fori=0tors.pagesize-1ifrs.boforrs.eofthenexitfor%><input...
怎样添加一个全选的复选框呢,,,,记录集有循环的,,,
<%
for i=0 to rs.pagesize-1
if rs.bof or rs.eof then exit for
%>
<input name="del" type="checkbox" id="del" value="<%=rs("ID")%>">
<%
rs.movenext()
next
%> 展开
<%
for i=0 to rs.pagesize-1
if rs.bof or rs.eof then exit for
%>
<input name="del" type="checkbox" id="del" value="<%=rs("ID")%>">
<%
rs.movenext()
next
%> 展开
展开全部
javascript来实现,把下面的js代码一字不漏地COPY到<head></head>间,能实现全选和反选功能:
<script language="javascript">
<!--//
function chooseAll(multiChk){
for (var i=0;i<multiChk.length;i++)
{
multiChk[i].checked = true;
}
}
function reserveAll(oj){
var oj = document.all["shenhe"]; //注意把[]里的shenhe改为你的del
for(var i=0;i<oj.length;i++){
if(oj[i].checked == true)
oj[i].checked = false;
else oj[i].checked = true;
}
}
// -->
</script>
<%'-----------你的原代码------------%>
在后面加上:
方法一:用复选框和文字完成
<input type="checkbox" name="shnehe" value="checkbox" onclick="chooseAll(document.all.shenhe)"><a href="javascript:chooseAll(document.all.shenhe)">全睁念选</斗迅a>
<input type="checkbox" name="shnehe" value="checkbox" onclick="reserveAll(document.all.shenhe)"><a href="javascript:reserveAll(document.all.shenhe)">反选</a>
-------------------------------------------------------------
方法二:用复选框和按钮完成
<input type="checkbox" name="checkbox" onclick="chooseAll(document.all.shenhe)"> <input type="button" value="全选" onclick="chooseAll(document.all.shenhe)">
<input type="checkbox" name="checkbox" onclick="reserveAll(document.all.shenhe)"> <input type="button" value="反选悉销困" onclick="reserveAll(document.all.shenhe)">
<script language="javascript">
<!--//
function chooseAll(multiChk){
for (var i=0;i<multiChk.length;i++)
{
multiChk[i].checked = true;
}
}
function reserveAll(oj){
var oj = document.all["shenhe"]; //注意把[]里的shenhe改为你的del
for(var i=0;i<oj.length;i++){
if(oj[i].checked == true)
oj[i].checked = false;
else oj[i].checked = true;
}
}
// -->
</script>
<%'-----------你的原代码------------%>
在后面加上:
方法一:用复选框和文字完成
<input type="checkbox" name="shnehe" value="checkbox" onclick="chooseAll(document.all.shenhe)"><a href="javascript:chooseAll(document.all.shenhe)">全睁念选</斗迅a>
<input type="checkbox" name="shnehe" value="checkbox" onclick="reserveAll(document.all.shenhe)"><a href="javascript:reserveAll(document.all.shenhe)">反选</a>
-------------------------------------------------------------
方法二:用复选框和按钮完成
<input type="checkbox" name="checkbox" onclick="chooseAll(document.all.shenhe)"> <input type="button" value="全选" onclick="chooseAll(document.all.shenhe)">
<input type="checkbox" name="checkbox" onclick="reserveAll(document.all.shenhe)"> <input type="button" value="反选悉销困" onclick="reserveAll(document.all.shenhe)">
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
参考信裂代码如下:
protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
{//复选
if (CheckBox2.Checked == true)
{
CheckBox2.Text = "全选";
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
cbox.Checked = true;
}
}
else
{
CheckBox2.Text = "全滑尺闭不选";
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("困尺CheckBox1");
cbox.Checked = false;
}
}
}
protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
{//复选
if (CheckBox2.Checked == true)
{
CheckBox2.Text = "全选";
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
cbox.Checked = true;
}
}
else
{
CheckBox2.Text = "全滑尺闭不选";
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("困尺CheckBox1");
cbox.Checked = false;
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
加上属性 checked="森冲checked"
<%
for i=0 to rs.pagesize-1
if rs.bof or rs.eof then exit for
%>
<input name="del" type="checkbox" checked="此简歼checked" id="del" value="<%=rs("ID")%>">咐册
<%
rs.movenext()
next
%>
<%
for i=0 to rs.pagesize-1
if rs.bof or rs.eof then exit for
%>
<input name="del" type="checkbox" checked="此简歼checked" id="del" value="<%=rs("ID")%>">咐册
<%
rs.movenext()
next
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询