0

I'm working on a project (using the CodeIgniter framework) which contains a grid with a lot of checkboxes. On selecting a checkbox, a pop up (twitter bootstrap - modal) appears which contains statements and its respective sub-statements. Statements are to be selected using radio buttons and sub-statements are to be selected using checkboxes.

Eg: If I select the 1st statement, then I'm supposed to select its respective sub-statements and not that of the 2nd. In order to avoid selecting the other sub-statements, I have to disable them. How can I do that?

radio1: statement 1 (enable - selected) chckbox1: sub-stmt1 (selected) chckbox2: sub-stmt2 (may be selected or may not be)

radio2: statement 2 (enable - not selected) chckbox1: sub-stmt1 (disable) chckbox2: sub-stmt2 (disable) chckbox3: sub-stmt3 (disable)

radio3: statement 3 (enable - not selected) chckbox1: sub-stmt1 (disable)

I'm using nested for loops, one for generating radio buttons (statements) and another for checkboxes (sub-statements).

3
  • Did you want to do this with jQuery?
    – Ali
    Commented May 6, 2013 at 8:04
  • He will need javascript anyway to open/close popup, to switch sub-statements, to..
    – Aurel
    Commented May 6, 2013 at 8:08
  • Please post your answer as an answer, not a comment to the question. Also, to make this question relevant to others in future, please post the relevant html. Commented May 6, 2013 at 10:24

1 Answer 1

0

I solved it in a different way

//hide checkboxes of other radio buttons if they are not selected selected

$(function() {

   $('#comment').on('change', '.toggle-family', function() { 

       if ($(this).attr('checked')) { 

            $("[name='cbox[]']").addClass('hide'); 
            $('.pi_'+$(this).val()).removeClass('hide'); 
       } 
   }); 

});

Thank you guys.

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.