+1 vote
191 views
in Programming by (1.8k points)
I want to Select and Delect all check box on click one check box i am using html and java script

Thanks for your answer!

2 Answers

0 votes
by (1.9k points)
Use  this script
<script type="text/javascript">
checked=false;
function checkedAllBox (formID) {
var aa= document.getElementById('formID');
if (checked == false)
          {
           checked = true
          }
        else
          {
          checked = false
          }
for (var i =0; i < aa.elements.length; i++) 
{
aa.elements[i].checked = checked;
}
      }
</script>
This is form 
<form id ="formID"> 
<input type="checkbox" name="chkbox1">
<input type="checkbox" name="chkbox2">
</form>
here is the checkbox which will select and deselect all checkboxes 
 <input type='checkbox' name='checkall' onclick='checkedAllBox(formID)'>
 

 

0 votes
by Expert (5.1k points)
  1. function checkCheckboxes() {
  2.     var e = document.getElementsByName("delId");
  3.     var message  = 'Are you sure you want to delete?';
  4.     var row_list = {length: 0};
  5.  
  6.     for (var i = 0; i < e.length; i++) {
  7.         var c_box = e[i];
  8.  
  9.         if (c_box.checked == true) {
  10.             row_list.length++;
  11.  
  12.             row_list[i] = {};
  13.             row_list[i].row = c_box.parentNode.parentNode;
  14.             row_list[i].tb  = row_list[i].row.parentNode;
  15.         }
  16.     }
  17.  
  18.     if (row_list.length > 0 && window.confirm(message)) {
  19.         for (i in row_list) {
  20.             if (i == 'length') {
  21.                 continue;
  22.             }
  23.  
  24.             var r = row_list[i];
  25.             r.tb.removeChild(r.row);
  26.         }
  27.     } else if (row_list.length == 0) {
  28.         alert('You must select an email address to delete');
  29.     }
  30. }

    use this it might be helpful!


 

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated