At this point, I'm exploring with the following test code, which I thought would display the state of the 4th checkbox - but found the value remained unchanged:
Code: Select all
<script language="JavaScript">
function CheckMax() {
alert("Picked something: " + document.forms[0].chk3.value);
}
</script>Can I interogate the value of the checkboxes from within the onclick event code, or does the onclick occur prior to the checkbox state being changed? Does CheckMax need to return "true" for the checkbox value to change.
Is there a bettter way?
My end goal is to tally the number of selected options, and provide a warning when the max allowable picks have been exceeded.
I'm thining of something like:
Code: Select all
function CheckMax(tnWhoCalled) {
j=0;
for (i=0; i<document.forms[0].TotalOptions.value; i+=1) {
eval('lnNextControlValue = document.forms[0].chk' + i + '.value') ;
if (lnNextControlValue > 0){
j=j+1;
}
}
if (document.forms[0].MaxPicks.value >= j) {
document.forms[0].StatusNumPicks.value = j ;
return true ;
}
else{
eval("document.forms[0].chk" + tnWhoCalled + ".value='0'") ;
return false ;
}
}
</script>Thanks in advance,
Michael