We know that in asp, as long as response.write request.form("checkboxName") can determine whether at least one item is selected, but it cannot be done until it is submitted, then we need to contact the scripting language js, vbs.
Assume that we have A checkbox is called optHSCameratyp. We write a function to determine whether
function chkCheckBoxChs(objNam){ //Check whether at least one item of the multi-select box is selected.
var obj = document.getElementsByName(objNam); //Get the multi-select box array
var objLen= obj.length; //Get the data length
var objYN; //Whether there is a choice
var i;
objYN=false;
for (i = 0;i< objLen;i++){
if (obj [i].checked==true) {
objYN= true;
break;
}
}
return objYN;
}
Then call this in the submission program:
function okSend()
{
if(chkChsHSC(optHSCameratyp)== false){
alert('Please select at least one item!');
}
return;
}
Because there are multiple checkboxes, The names are the same, so in js if simple document.all.checkboxNam cannot identify which control it is, document.getElementsByName must be used as an array to distinguish them.