如果下拉框选择的是查询员,则禁用所以复选框。如果不是则启用。
大侠们给点解决方案。谢谢
解决方案 »
- 客户端用js读取文件,转换成二进制格式字符串传送到后台存入数据库
- 同志儿们,help
- 请教各位大仙两个页面之间传参数问题
- ★☆★[急]往app_data目录加access数据库时报“处理本地数据文件时发生错误:未将对象引用设置到对象的实例”
- 跨层接收数组!!!
- 数据处理乱码问题
- asp.net图片显示问题
- 用数据库保存图片后,图片不能正常显示,可能的原因有几种?
- 关于stream的问题。web services 传递附件。请高手指点!
- asp.net中关于数据库image字段的读些问题--up有分
- asp.net如何在gridview中显示图片!
- 【急】求高手指教,repeat中怎么给图片绑js属性,问题描述间内容...
{
//不是,启用
CheckBox1.Enabled = true;
}
else
{
//是,禁用
CheckBox1.Enabled = false;
}
不行啊。那个CHECKbox是客户端控件,而且ID是动态生成的。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
//方法1: jquery
function test_jQuery(obj){
$("#div1 :checkbox").prop("disabled",obj.value==="3");
}
//方法2: 纯js
function test(obj){
var chks = document.getElementById("div1").getElementsByTagName("input");
for(var i=0;i<chks.length;i++){
if(obj.value==="3"){
chks[i].setAttribute('disabled','disabled');
}else{
chks[i].removeAttribute('disabled');
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Text="请选择" Value=""></asp:ListItem>
<asp:ListItem Text="录入员" Value="1"></asp:ListItem>
<asp:ListItem Text="管理员" Value="2"></asp:ListItem>
<asp:ListItem Text="查询员" Value="3"></asp:ListItem>
</asp:DropDownList>
<div id="div1" >
<input type="checkbox" />财务部<br />
<input type="checkbox" />审计部<br />
<input type="checkbox" />纪委<br />
</div>
</form>
</body>
</html>
页面后置文件:using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;public partial class ULTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.DropDownList1.Attributes.Add("onchange","test(this)");
}
}
}