0

I have a little problem with JS function that I created in the Pic that I attached there is 2 CheckBoxes: CbMale,CbFemale and a button for ChangeSelection.. I want that when the CbMale is checked the CbFemale will be disabled and after the user click on the ChangeSelection button there is a message that asking if he want to change selection if he does click ok the two checkbox are enabled and unchecked...and going vice versa if he click on the cbFemale first.

![A picture of two check boxes labelled ‘male’ and ‘female’ with a button labelled ‘change gender’ after them.][1]

My JS:

  function ChangeSelection(sender, args) {
        radconfirm('Would you like to change gender?</br>', confirmDisableCallBackFn, 370, 200, null, 'Alert');
    }

     function confirmDisableCallBackFn(arg) {
         if (arg == true) {
             var cbMale = $find("<%=cbMale.ClientID %>");
             var cbFemale = $find("<%=cbFemale.ClientID %>");
             //check.set_checked(false);
             cbFemale.set_enabled(true);
             cbMale.get_checked(false);

         }
         else {
             check.set_checked(true); 
         }
     }

    function ChangeGender(sender, args) {
        var cbMale = $find("<%=cbMale.ClientID %>");
        var cbFemale = $find("<%=cbFemale.ClientID %>");
        if (cbMale.get_checked(true)) {
            cbFemale.set_enabled(false);
        } else {
            cbMale.set_enabled(false);
        }
     }

My asp Code:
 <telerik:RadButton ID="cbMale" runat="server" ToggleType="CheckBox" ButtonType="ToggleButton" AutoPostBack="False" Text="Male" OnClientClicked="ChangeGender" ></telerik:RadButton>
                               <telerik:RadButton ID="cbFemale" runat="server" ToggleType="CheckBox" ButtonType="ToggleButton" AutoPostBack="False" Text="Female"></telerik:RadButton>
                                <telerik:RadButton ID="btnEditPersonDescription" runat="server" Text="Change Gender" Width="120px" AutoPostBack="false" OnClientClicked="ChangeSelection">
                                <Icon PrimaryIconCssClass="rbEdit" PrimaryIconLeft="4" PrimaryIconTop="4"></Icon></telerik:RadButton>

https://i.sstatic.net/OBpgK.png

1 Answer 1

2

You are trying to simulate the behavior of radio buttons with check boxes. Its easier with radio buttons. If you select cbMale it will not allow you to select cbFemale and vice versa. So create a group of radio buttons.

---Edit--- http://www.w3schools.com/aspnet/showaspx.asp?filename=demo_radiobutton Please take a look at the demo. It will guide you.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry but I didn't meant that...I'm trying actually as you said to simulate the behavior of radio buttons with check boxes and also I have Rad Button the thing is: when you click on 1 check boxe like CbMale it will dimmed the CbFemale and in order to undimmed the CbFeamle e.g to change selection he needs to click on the button when he will click on the button it will ask him if he want to change is choise once he click yes the two check boxes are undimmed and unchecked so he can pick again his choise! can you please show me that?? I tried to do this with JS function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.