Click here to Skip to main content
15,998,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello

i have 4 chackboxes when i select one other three checkboxes should be checked
Posted
Comments
debasis behera 28-May-13 5:43am    
Please accept this answer, if it has helped you in any way.
This will help others to find the answer in one go and you will also be awarded with some points for this action...

Thanks,
Debasis
Member 9815058 28-May-13 5:46am    
I Already accept it

1 solution

Hii

This will help! :)


XML
<div id="checkBoxDiv">
    <input type="checkbox" class="chkSiteBox" onclick="selectAllCheckBoxs(this,'checkBoxDiv')"  value="1" id="chkBox1" name="_chkBox1">
    <input type="checkbox" class="chkSiteBox" onclick="selectAllCheckBoxs(this,'checkBoxDiv')"  value="1" id="chkBox2" name="_chkBox2">
    <input type="checkbox" class="chkSiteBox" onclick="selectAllCheckBoxs(this,'checkBoxDiv')"  value="1" id="chkBox3" name="_chkBox3">
    <input type="checkbox" class="chkSiteBox" onclick="selectAllCheckBoxs(this,'checkBoxDiv')"  value="1" id="chkBox4" name="_chkBox4">
</div>


Then js code:

C#
function selectAllCheckBoxs(tis,id) {

    $('#'+id).find('input[type="checkbox"]').each(function(i){

        if($(tis).attr("checked")) {
            $(this).attr("checked", true);

        } else {
            $(this).attr("checked", false);

        }
    });

}
 
Share this answer
 
Comments
Member 9815058 28-May-13 5:35am    
Thank You So Much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900