Copy codeThe Code is as follows:
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
<Script type = "text/javascript" language = "javascript">
Function selectAll ()
{
Var allCheckBoxs = document. getElementsByName ("coffee ");
Var desc = document. getElementById ("like ");
If (desc. value = "")
{
Desc. value = "NONE ";
For (var I = 0; I <allCheckBoxs. length; I ++)
{
AllCheckBoxs [I]. checked = true;
}
}
Else
{
Desc. value = "all ";
For (var I = 0; I <allCheckBoxs. length; I ++)
{
AllCheckBoxs [I]. checked = false;
}
}
}
</Script>
</Head>
<Body>
<P> type of coffee you like </p>
<Form>
<Input type = "checkbox" name = "coffee" value = "cream"> Blue Mountain coffee <br>
<Input type = "checkbox" name = "coffee" value = "sugar"> Moka <br>
<Input type = "checkbox" name = "coffee" value = "sugar"> latte <br>
<Input type = "checkbox" name = "coffee" value = "sugar"> cappuccino <br>
<Input type = "checkbox" name = "coffee" value = "sugar"> Irish coffee <br>
<Input type = "button" id = "like" value = "on" onClick =" selectAll () ">
</Form>
</Body>
</Html>