Change button's enabled property via checkbox

Posted by Ivan Stoyanov on Stack Overflow See other posts from Stack Overflow or by Ivan Stoyanov
Published on 2010-04-06T12:25:38Z Indexed on 2010/04/06 12:33 UTC
Read the original article Hit count: 279

I tried this javascript but it doesn't work - here

I need to change the button's enabled property to true when the checkbox is checked and to false when it isn't. This is my code.

<tr>
  <td colspan="2" align="center">
    <asp:CheckBox ID="cbAcceptAgreement" runat="server" OnClientClick="acceptAgreement(this)" />
    <asp:Label ID="lblUserAgreement" runat="server" Text="I accept the " />
    <asp:HyperLink ID="hlUserAgreement" runat="server" Text="User Agreement" NavigateUrl="Help/UserAgreement.aspx" />
  </td>
</tr>
<tr>
  <td colspan="2" align="center">
    <asp:Button ID="btnRegister" runat="server" Text="Register"  />
  </td>
</tr>

<script type="text/javascript">
  function acceptAgreement(Obj) {
    document.getElementById('<%=btnRegister.ClientID%>').disabled = !obj.checked;
  }
</script>

Can you help me solve this problem?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript