Im not gonna do the code for you, but i'll explain the approach you should
use...
create a global variable eg. cCount
initially set it to 0 --> var cCount = 0
change you chkCount function to chkCount(targ) where targ will be sent as
onclick="chkCount(this)"
so you know which checkbox was clicked..
everytime you call your chkCount function do this..
check whether the chekbox is now checked or unchecked:
if (targ.checked) {
} else {
}...
check the value of cCount
if the box is being unchecked, simply do this: cCount-- and nothing else
(get that from ur condition above)
if it is being checked...
if less than 3, do nothing, just increment cCount --> cCount++
if not, then you don't want that one checked, so:
targ.checked = false
where targ is the checkbox that was just clicked...
you can alert the user and ask them to uncheck something first blah blah
i hope you get the picture...
come to think of it, i coulda just done the function for you..., but then
you won't learn will you :0)
good luck!
"Dave D." <da*****@charter.net> wrote in message
news:2f**************************@posting.google.c om...
I have a total of 8 checkboxes, but the user is only allowed to check
any three of them. After have been checked I have an alert box saying
that only 3 boxes can be checked. I'm trying to get so that it
disable's the checkboxes that are not checked, but then if one of the
three get unchecked, then all checkboxes become enabled again. Here's
my code so far....(In Javascript)
function chkCount()
{
var i = 0;
if (document.frmShortService.chkLH.checked) i++;
if (document.frmShortService.chkLTL.checked) i++;
...
if (i > 3)
{
alert("Only 3 Checkboxes can be checked");
return(false);
}
}
<input type="checkbox" name="chkLH" value="YES" onclick="chkCount()">
....
Thanks in Advance!
Dave