21 November 2009

select all checkboxes in single check

<html>
<title> select all checkboxes in single check
</title> 
<head>
 <script language=javascript>
checked=false;
function checkedAll (form1) {
    var aa= document.getElementById('form1');
     if (checked == false)
          {
           checked = true
          }
        else
          {
          checked = false
          }
    for (var i =0; i < aa.elements.length; i++)
    {
     aa.elements[i].checked = checked;
    }
      }
</script
</head>
 <body>
<form name="form1" method="post" id="form1">
<table>
    <tr>
       <td><input type='checkbox' name='checkall' onclick='checkedAll(form1);'> </td>
    </tr>
    <tr>
    <td> </td>
    </tr>
    <tr>
    <td>Checkbox1: <input type='checkbox' name='chk'value=""> </td>
    </tr>
    <tr>
    <td>Checkbox 2: <input type='checkbox' name='chk'value=""> </td>
    </tr>
</table>
</form>
</body>
</html>

No comments:

Post a Comment