<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <script src="../../js/calendar.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input id="ch" runat=server type=checkbox value="水电工" />
    <asp:TextBox ID="txtSJ2" runat="server"  onclick="meizz_calendar(this)" onfocus="this.blur();"
                                                            Width="7%" CssClass="input2"></asp:TextBox>
    </div>
    </form>
</body>
</html>
想实现checkbox 选中时候 TextBox ID="txtSJ2" 可以填写.未选中不可填写 

解决方案 »

  1.   

    <input id="ch" runat=server type=checkbox value="水电工" onclick='DoCheck(this, <%= this.txtSJ2.ClientID %>)' /><script language="javascript">
    function DoCheck(ctrl, id)
    {
       if(ctrl.checked)
       {
          document.all(id).disabled = false;
       }
       else
       {
          document.all(id).disabled = true;
       }
    }</script> 
      

  2.   

    <%=   this.txtSJ2.ClientID  这里是txtSJ2他的ID吗.按照你的没改的试了下还是不行
      

  3.   

    <input id= "ch " runat=server type=checkbox value= "水电工 " onclick= 'ch_onclick(this);' /> <script language= "javascript "> 
    function ch_onclick(obj) 

     if(obj.checked) 
     { 
       document.form1.txtSJ2.disabled = false; 
     } 
     else 
     { 
        document.form1.txtSJ2.disabled = true; 
     } 

    </script> 
      

  4.   

    加个name属性试试,IE6.0中,document.form1后面只能跟name属性,不能跟id。如果想用id的话,就必须用getElementById
      

  5.   

    sorry,少写个引号:<input id= "ch" runat=server type=checkbox value= "水电工" onclick='DoCheck(this,"<%=this.txtSJ2.ClientID%>")' />如果你是用VB.NET开发,那么this.txtSJ2.ClientID改为Me.txtSJ2.ClientID。注意:WebControl的ID和ClientID绝对不一样。