0

I'm trying to get the the proceed button to get enabled after the checkbox has been ticked. I'm a beginner and not sure what I'm missing.

<asp:CheckBox ID="chkBoxProceed" runat="server" OnClick="chkProceed();" />

<asp:Button ID="btnProceed" runat="server" Text="<%$Resources:Strings,ACC_ProceedToApplyForAccreditation%>"
                    OnClick="btnProceed_Click" CssClass="govuk-button" disabled/>

Here's what I've tried so far/found;

function chkProceed() {
        if (document.getElementById("chkBoxProceed").checked)
            document.getElementById("btnProceed").disabled = false;
        else
            document.getElementById("btnProceed").disabled = true;
    }
Cbear
  • 17
  • 5
  • And what issue you are facing with this code? You might want to use server side event handler for checkbox's checkchanged event. https://www.c-sharpcorner.com/UploadFile/f50501/oncheckedchanged-event-of-checkbox-control-in-Asp-Net/ – Chetan Oct 28 '19 at 12:58
  • Nothing happens. The button stays disabled regardless of if the checkbox is ticked or not. – Cbear Oct 28 '19 at 13:57

1 Answers1

0

The attribute OnClientClick can't be understood by the browser. You should use OnClick instead.

Change this code

<asp:CheckBox ID="chkBoxProceed" runat="server" OnClientClick="chkProceed();" />

To this

<asp:CheckBox ID="chkBoxProceed" runat="server" OnClick="chkProceed();" />

For more information check this answer

Shady Mohamed Sherif
  • 15,003
  • 4
  • 45
  • 54