请教一段javascript代码该怎么写?急!!! 哦,你可以看看运行结果源文件,就是运行页面,然后 查看=>源文件,里面的什么checkboxlist好像都是用表格来控制格式的,然后根据客户端的dom来循环访问设置其状态 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CheckBox1在客户端根据ID就可以更改值Document.Form.CheckBox1.value=true;就可以了 <HTML> <HEAD> <title id="mytitle">WebForm1</title> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> <script language="javascript"> function checkall(obj) { var icount=0; for(icount=0;icount<document.all.length;icount++) { if(document.all[icount].id.substring(0,13)=="CheckBoxList1") { if(obj.checked==true) { document.all[icount].checked=true; } else { document.all[icount].checked=false; } } } } </script> </HEAD> <body MS_POSITIONING="FlowLayout"> <form id="Form1" method="post" runat="server"> <FONT face="宋体"><INPUT style="WIDTH: 48px; HEIGHT: 20px" type="checkbox" id="mychk" onclick="checkall(this)"> <asp:CheckBoxList id="CheckBoxList1" runat="server"> <asp:ListItem Value="item1">item1</asp:ListItem> <asp:ListItem Value="item2">item2</asp:ListItem> <asp:ListItem Value="item3">item3</asp:ListItem> </asp:CheckBoxList></FONT></form> </body></HTML>------------------------------------------------------------------------------注意:if(document.all[icount].id.substring(0,13)=="CheckBoxList1")是因为CheckBoxList的id是CheckBoxList1,如下:<asp:CheckBoxList id="CheckBoxList1" runat="server"> 以下代碼未經實測//代入兩個參數,要控制的控件名和控件的數量this.CheckBox1.Attributes["onclick"]="jscript:on_click("+CheckBoxList1.clientid+","+CheckBoxList1.items.count.tostring()+");";js代碼類似以下function on_click(obj,MaxIndex){ for(var i=0;i<MaxIndex;i++){ (eval(obj+"_"+i)).selected=true; }} 以下代碼未經實測//代入兩個參數,要控制的控件名和控件的數量this.CheckBox1.Attributes["onclick"]="jscript:on_click("+CheckBoxList1.clientid+","+CheckBoxList1.items.count.tostring()+");";js代碼類似以下function on_click(obj,MaxIndex){ for(var i=0;i<MaxIndex;i++){ (eval(obj+"_"+i)).selected=true; }} 这段代码需要什么引用? 如何用jquery获取下面控件的值啊 控件大小 用VS.NET2005做asp.net页面时,如何来做页面布局啊?借什么工具?DR? 关于FCKeditor插入图片的问题??? 保存状态的问题?急!先谢了 关于ASP.NET树控件和框架网页结合后的速度问题,请大家畅所欲言。。。 关于相对路径的问题 请问大家,javascript可以打开一个三个按钮的对话框吗? 数据库连接的问题,请大虾指点!!! webservice+xml+javascript实现局部刷新 怎样判断一个textbox中输入的是字符??? 高手指点!!
<HEAD>
<title id="mytitle">WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="javascript">
function checkall(obj)
{
var icount=0;
for(icount=0;icount<document.all.length;icount++)
{
if(document.all[icount].id.substring(0,13)=="CheckBoxList1")
{
if(obj.checked==true)
{
document.all[icount].checked=true;
}
else
{
document.all[icount].checked=false;
}
}
}
}
</script>
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体"><INPUT style="WIDTH: 48px; HEIGHT: 20px" type="checkbox" id="mychk" onclick="checkall(this)">
<asp:CheckBoxList id="CheckBoxList1" runat="server">
<asp:ListItem Value="item1">item1</asp:ListItem>
<asp:ListItem Value="item2">item2</asp:ListItem>
<asp:ListItem Value="item3">item3</asp:ListItem>
</asp:CheckBoxList></FONT></form>
</body>
</HTML>
------------------------------------------------------------------------------
注意:if(document.all[icount].id.substring(0,13)=="CheckBoxList1")
是因为CheckBoxList的id是CheckBoxList1,如下:
<asp:CheckBoxList id="CheckBoxList1" runat="server">
//代入兩個參數,要控制的控件名和控件的數量
this.CheckBox1.Attributes["onclick"]="jscript:on_click("+CheckBoxList1.clientid+","+CheckBoxList1.items.count.tostring()+");";js代碼類似以下
function on_click(obj,MaxIndex){
for(var i=0;i<MaxIndex;i++){
(eval(obj+"_"+i)).selected=true;
}
}
//代入兩個參數,要控制的控件名和控件的數量
this.CheckBox1.Attributes["onclick"]="jscript:on_click("+CheckBoxList1.clientid+","+CheckBoxList1.items.count.tostring()+");";js代碼類似以下
function on_click(obj,MaxIndex){
for(var i=0;i<MaxIndex;i++){
(eval(obj+"_"+i)).selected=true;
}
}