Hi guys,

I need some help with this javascript on a form. It does some of what I need, I just need help completing it.

To explain I have 20 checkboxes on a form each representing a category. The 1st part of the javascript prompts people to check between 1 and 5 categories (checkboxes). This works fine and does not need work.

The rest of the javascript opens and closes sections of the form depending on which checkboxes are selected. For example if checkbox id 'sobi2SlectedCatsID_1' or 'sobi2SlectedCatsID_1' are selected then a section (div) called 'modeling_section' appears.

The problem I have with the script is that if I select 'sobi2SlectedCatsID_1' or 'sobi2SlectedCatsID_1' are selected it opens the 'modeling_section' which is fine.
If I select 'sobi2SlectedCatsID_1' AND 'sobi2SlectedCatsID_1' it opens the 'modeling_section' which is fine.
But when I select 'sobi2SlectedCatsID_1' AND 'sobi2SlectedCatsID_1' and it opens the 'modeling_section' and then I unselect one of them it closes the 'modeling_section' instead of leaving it open. This is the same for the rest of the conditional statements as well. How do I fix this.

The other thing is that this form can be brought up and re-edited by the user. When the user reopens the form to adjust it the form remembers which checkboxes the user selected last time they used the form but it doesn't remember which sections it had opened.

Here is the javascript, hope it makes sense.

Code:
function boxchk(obj,max) {
	var box = obj.id.substr(0,obj.id.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 + ' category checkboxes.\nTo pick this option unselect one of the others.');
		}
	if (cnt == 0) {
		obj.checked = false;
		alert('You must Select at least one category checkbox.');
		}		
	if (obj.id == 'sobi2SlectedCatsID_1' || obj.id == 'sobi2SlectedCatsID_2') {
		var vis = (obj.checked) ? 'block' : 'none';
		document.getElementById('modeling_section').style.display = vis;
		}
	if (obj.id == 'sobi2SlectedCatsID_5' || obj.id == 'sobi2SlectedCatsID_7') {
		var vis = (obj.checked) ? 'block' : 'none';
		document.getElementById('music_section').style.display = vis;
		}
	if (obj.id == 'sobi2SlectedCatsID_3' || obj.id == 'sobi2SlectedCatsID_4') {
		var vis = (obj.checked) ? 'block' : 'none';
		document.getElementById('acting_section').style.display = vis;
		}
	if (obj.id == 'sobi2SlectedCatsID_6') {
		var vis = (obj.checked) ? 'block' : 'none';
		document.getElementById('dancing_section').style.display = vis;
		}
	if (obj.id == 'sobi2SlectedCatsID_8' || obj.id == 'sobi2SlectedCatsID_9' || obj.id == 'sobi2SlectedCatsID_10' || obj.id == 'sobi2SlectedCatsID_11' || obj.id == 'sobi2SlectedCatsID_12' || obj.id == 'sobi2SlectedCatsID_13' || obj.id == 'sobi2SlectedCatsID_14' || obj.id == 'sobi2SlectedCatsID_15' || obj.id == 'sobi2SlectedCatsID_16' || obj.id == 'sobi2SlectedCatsID_17' || obj.id == 'sobi2SlectedCatsID_18' || obj.id == 'sobi2SlectedCatsID_19' || obj.id == 'sobi2SlectedCatsID_20') {
		var vis = (obj.checked) ? 'block' : 'none';
		document.getElementById('business_section').style.display = vis;
		}
	if (obj.id == 'sobi2SlectedCatsID_1' || obj.id == 'sobi2SlectedCatsID_2' || obj.id == 'sobi2SlectedCatsID_3' || obj.id == 'sobi2SlectedCatsID_4' || obj.id == 'sobi2SlectedCatsID_5' || obj.id == 'sobi2SlectedCatsID_6') {
		var vis = (obj.checked) ? 'block' : 'none';
		document.getElementById('physical_details_section').style.display = vis;
		}
}