no

How to Select All Checkbox or Element in a Form Html

Creating a form dynamically at run time – this also means we should give unique names to each html controls. For example we have a datagrid ...

Creating a form dynamically at run time – this also means we should give unique names to each html controls. For example we have a datagrid like object and its first column is checkbox, how should we check all of the rows.

Here is my code that iterates to all controls in an html document and check if it is CheckBox type:

//flag can have the value of 1 = checked, else unchecked
function checkAll(flag) {    
  var f = document.forms["yourformname"], i;     
    for(i = 0; i < f.length; i++){ //iterate to each control    
      if(f[i].type == 'checkbox'){ //if type checkbox    
        if(flag == 1)     
          f[i].checked = true;     
        else     
          f[i].checked = false;     
       }     
    }     
}

Related

web 7531112996923104587

Post a Comment Default Comments

item