0

hi i want to enable the the checkboxes again if user has uncheck the checkboxes which was checked. however in my case case the id and name of the element should to be same. checkboxes are getting disabled on the basis of their values and in the same way i want to enable them back...

  <input type="checkbox" value="1"  id="preferenceid" name="preferenceid">
  <span>MBA</span>          
  <input type="checkbox" value="2"  id="preferenceid" name="preferenceid">
  <span>Integrated MBA</span>           
  <input type="checkbox" value="3"  id="preferenceid" name="preferenceid">
  <span>MBA/PhD</span>          
  <input type="checkbox" value="4"  id="preferenceid" name="preferenceid">
  <span>Diploma</span>          
  <input type="checkbox" value="5"  id="preferenceid" name="preferenceid">
  <span>BA(Mass Communication)</span>           
  <input type="checkbox" value="6"  id="preferenceid" name="preferenceid">
  <span>BBA</span>




<script type='text/javascript'>
    $('#preferenceid[value="1"],#preferenceid[value="2"],#preferenceid[value="3"],#preferenceid[value="4"]').click(function () {
                $('#preferenceid[value="5"],#preferenceid[value="6"]').attr("disabled",true);
            });


        $('#preferenceid[value="5"],#preferenceid[value="6"]').click(function () {
            $('#preferenceid[value="1"],#preferenceid[value="2"],#preferenceid[value="3"],#preferenceid[value="4"]').attr("disabled",true);

        });


           if($('#preferenceid[value="1"],#preferenceid[value="2"],#preferenceid[value="3"],#preferenceid[value="4"]').attr('checked')) {
            $('#preferenceid[value="5"],#preferenceid[value="6"]').attr("disabled",true);
        }

        if($('#preferenceid[value="5"],#preferenceid[value="6"]').attr('checked')) {
            $('#preferenceid[value="1"],#preferenceid[value="2"],#preferenceid[value="3"],#preferenceid[value="4"]').attr("disabled",true);

        }
</script>
3
  • 2
    The id for an element must be unique — you should pay a visit to validator.w3.org (Oh, and your span elements would be better expressed as label (with appropriate for attributes) Commented Apr 4, 2011 at 8:48
  • thanks for your information david..reason is that i have to generate the id's dynamically.. Commented Apr 4, 2011 at 9:28
  • It still isn't allowed. Generate different ids dynamically. Commented Apr 4, 2011 at 9:28

1 Answer 1

1

Disable And Enable Input Elements In A Div Block Using jQuery

look here please. and don't forget to make element id unique

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

Comments

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.