i am passing the class and id of chechboxes to the js function and try to make it dynamic to work for id and class of any checkbox to check all and uncheck all check boxes here is the html \[code\] <input type="checkbox" name="reply_status[]" <?=$checked;?> class="memebers" value="http://stackoverflow.com/questions/10550468/<?=$status[$e]['mail_sent_id']?>"> </td> <td> <input type="checkbox" name="send_invoice[]" <?=$checked_send_invoice;?> class="send_invoice" value="http://stackoverflow.com/questions/10550468/<?=$status[$e]['mail_sent_id']?>"> </td> <td> <input type="checkbox" name="invoice_paid[]" <?=$checked_invoice_paid;?> class="invoice_paid" value="http://stackoverflow.com/questions/10550468/<?=$status[$e]['mail_sent_id']?>"> </td><td> <input type="checkbox" id="check_all_re" name="check_all" onclick="checkall_members('memebers','check_all_re')"> Check All </td> <td> <input type="checkbox" id="check_all_sv" name="check_all" onclick="checkall_members('send_invoice','check_all_sv')"> Check All </td> <td> <input type="checkbox" id="check_all_ip" name="check_all" onclick="checkall_members('invoice_paid','check_all_ip')"> Check All </td>\[/code\]and here is the js function\[code\]<script type="text/javascript">function checkall_members(chechboxclass, chechboxid) { // var id = document.getElementById("check_all"); alert(); chechboxid = $('#' + chechboxid); chechboxclass = $('.' + chechboxclass); if (chechboxid.checked) { chechboxclass.attr('checked', 'checked'); } else { chechboxclass.removeAttr('checked'); }}\[/code\]any help would be appreciated