Page 1 of 1

Control over Multiple Group Checkbox in a form

Posted: Mon Apr 19, 2010 5:41 am
by thamizh
<script language="javascript">
function boxchk1(obj,max) {
var box = obj.name.substr(0,obj.name.lastIndexOf('_')+1);
var cnt=0,i=1;
while(obj.form[box+i])
{
cnt += obj.form[box+i].checked;i++;
}
if (cnt > max)
{
obj.checked = false;
alert('Only choose ' + max + ' '+box.substr(0,box.length-1) +' checkboxes.\nTo pick this option unselect one of the others.');
}
}
</script>


am using above script, this script control all the group checkboxes in the form ,but i have 2 to 3 checkbox group each group should have only one checkbox checked how to do this anybody help me pls :(

Re: Control over Multiple Group Checkbox in a form

Posted: Mon Apr 19, 2010 11:54 am
by omniuni
Is there a reason you don't want to use radio buttons instead?

Re: Control over Multiple Group Checkbox in a form

Posted: Tue Apr 20, 2010 8:41 am
by thamizh
yes changed all the checkboxes to radio buttons
now i got the desired result thanks a lot :)