<Input type = checkbox name = mm value = a onclick = "checkItem (this, 'mmall')"> <br>
<Input type = checkbox name = mm value = B onclick = "checkItem (this, 'mmall')"> <br>
<Input type = checkbox name = mm value = c onclick = "checkItem (this, 'mmall')"> <br>
<Input type = checkbox name = mm value = d onclick = "checkItem (this, 'mmall')"> <br>
<Input type = checkbox name = mm value = e onclick = "checkItem (this, 'mmall')"> <br>
<Input type = checkbox name = mmAll onclick = "checkAll (this, 'mm')"> select all or not
<Script language = javascript>
Function checkAll (e, itemName)
{
Var aa = document. getElementsByName (itemName );
For (var I = 0; I <aa. length; I ++)
Aa [I]. checked = e. checked;
}
Function checkItem (e, allName)
{
Var all = document. getElementsByName (allName) [0];
If (! E. checked) all. checked = false;
Else
{
Var aa = document. getElementsByName (e. name );
For (var I = 0; I <aa. length; I ++)
If (! Aa [I]. checked) return;
All. checked = true;
}
}
</Script>
Ps: (of course, if the all-selected box is another control, such as a button or a link, the checkItem click event in the check box can be removed to avoid errors)