...

View Full Version : Is there a shortcut key to select all checkboxes in a form?



Coolvirus
09-03-2002, 06:15 PM
Like the question says, is there some sort of shortcurt like a key combo or something else to select all checkboxes in a form at once instead of having to click one at a time?

Thank you in advance.

requestcode
09-03-2002, 07:04 PM
There is no browser specific shortcut, but you can use JavaScript to perfrom that function. Here is an example where all the checkbox's have the same name:
<html>
<head>
<title>Check All</title>
<SCRIPT LANGUAGE="JavaScript">
function checkall(formid)
{
len=formid.ckb.length
for(i=0;i<len;i++)
{
formid.elements.ckb[i].checked=true
}
}
function uncheckall(formid)
{
len=formid.ckb.length
for(i=0;i<len;i++)
{
formid.elements.ckb[i].checked=false
}
}
</SCRIPT>
</head>
<body>
<CENTER>
<FORM NAME="myform">
<INPUT TYPE="checkbox" NAME="ckb"> Checkbox One
<BR>
<INPUT TYPE="checkbox" NAME="ckb"> Checkbox Two
<BR>
<INPUT TYPE="checkbox" NAME="ckb"> Checkbox Three
<BR>
<INPUT TYPE="button" NAME="chka" VALUE="Check All" onClick="checkall(this.form)">
<INPUT TYPE="button" NAME="unchka" VALUE="Uncheck All" onClick="uncheckall(this.form)">
</FORM>
</CENTER>
</body>
</html>

Coolvirus
09-03-2002, 07:22 PM
Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum