During Web development, you often need to select and cancel all checkpoints on the page.
HTML code of the page
<Input type = 'checkbox' name = 'info' value = 'A'>
<Input type = 'checkbox' name = 'info' value = 'B'>
<Input type = 'checkbox' name = 'info' value = 'C'>
<Input type = 'checkbox' name = 'info' value = 'D'>
<Input type = 'checkbox' name = 'info' value = 'E'>
<Br/>
<Input type = 'button 'value = 'select all 'onclick = 'check _ all ();'>
<Input type = 'button 'value = 'cancel all 'onclick = 'check _ all_un ();'>
Corresponding JavaScript code
<Script>
Function check_all ()
{// Select all
Arr = document. getElementsByName ('info ');
For (I = 0; I <arr. length; I ++)
{
Arr [I]. checked = true;
}
}
Function check_all_un ()
{// Cancel all
Arr = document. getElementsByName ('info ');
For (I = 0; I <arr. length; I ++)
{
Arr [I]. checked = false;
}
}
</Script>