Avatar of David Megnin
David Megnin
Flag for United States of America

asked on 

Check a CheckBox when any RadioButtonList Items are selected

Hi Experts,

I've a CheckBox and a RadioButtonList on an .aspx page and would like to "Check" the CheckBox if any of the RadioButtonList Items are selected.  I've tried several versions of this and can't get it to work.  Obviously I don't know JavaScript very well. ;-)

.aspx
<asp:CheckBox ID="SeeSuccessCoach" runat="server" Text="To see my Success Coach -" />
<asp:RadioButtonList ID="radCaseManager" runat="server" RepeatDirection="Horizontal"
    RepeatLayout="Flow" Font-Size="Smaller" Onclick="SetSeeCoach('SeeSuccessCoach');">
    <asp:ListItem Value="SNAP" Text="SNAP" />
    <asp:ListItem Value="WIA" Text="WIA" />
    <asp:ListItem Value="WTP" Text="WTP" />
    <asp:ListItem Value="REA" Text="REA" />
    <asp:ListItem Value="TTW" Text="Ticket-to-Work or" />
    <asp:ListItem Value="Vet" Text="Veteran" />
</asp:RadioButtonList>

Open in new window

.js
    function SetSeeCoach(QuestionID) {
        var rad = QuestionID
        var ckBox = document.getElementById(rad);
        ckBox.Checked = true
    }

Open in new window

.aspx.vb
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
radCaseManager.Attributes.Add("onclick", "SetSeeCoach();")
    End Sub

Open in new window


Help greatly appreciated.  Thanks.

Oh, clearing/unselecting the RadioButtonList Item if the CheckBox is unchecked would be a big plus.
Thanks!
JavaScriptASP.NET

Avatar of undefined
Last Comment
David Megnin

8/22/2022 - Mon