I have a form with a staticlist field called 'Locations'. Choices are location1, location2, etc. I also have corresponding MVCheckbox fields called 'Location1 areas', 'Location2 areas', etc. I want all of the MVCheckbox fields hidden when the form loads, and then based on the choice from the staticlist Location fields, display the corresponding MVCheckbox field, and make it required. So if choice from Locations field is location1, display MVCheckbox field 'Location1 areas', make it required, able to choose multiple areas.

How should I set this up?

Currently I have all MVCheckbox fields as visible=False, and an have an onchange event set up on locations field:

if(form.getValue("locations") == 'location1')
{
form.show("location1Areas");
form.setRequired("location1Areas", true);
form.hide("location2Areas");
form.setRequired("location2Areas", false);

}

....and so on, to cover possible choices in Locations field. When I make a selection from the Locations field, the correct Areas field does display, but no choices display. Choices are set up in the List Items area for that field in the form, and if I have the field set to visible=true so that it shows up when the form is first loaded, it does display correctly. It just doesn't display correctly when it is set to visible and required by the onchange event.