Translating Data Values for Check Boxes

The Group and User form views include check boxes. The data that translates into checked or unchecked states for the check boxes resides in one string, not in separate Boolean fields. The check boxes on the User form relate to the ReleaseInfo column in the Person table; the check boxes on the Group form represent the MeetingDays column in the Group table. The two forms translate data values identically.

A hidden field on the form contains the value of the MeetingDays column. An array named cks consists of seven elements, one for each of the check boxes on the Group form view. The following code fragment from Group.htm executes when the page first loads:

var chks = new Array("chkMeetingDays0","chkMeetingDays1",
                     "chkMeetingDays2","chkMeetingDays3",
                     "chkMeetingDays4","chkMeetingDays5",
                     "chkMeetingDays6"); 

When the XML data is fully loaded, the loaded function is called. The following line of code from the loaded function in Group.js specifies the event handler to be called when the readystate property of GroupRecord changes.

GroupRecord.onreadystatechange = setInfo;

The setInfo function, which the following code illustrates, sets the state (1= checked and 0= unchecked) for each check box in the cks array:

function setInfo() {
   if (GroupRecord.readyState == 'complete') {
      var info = document.frmGroup.MeetingDays.value;
      for (var i=0; i<info.length; i++) {
         document.all(chks[i]).checked = (info.substr(i,1)=="1"?true:false);
      }
   }
}

The code the setInfo function in Person.js works in a similar way to translate the check box values for Person.htm.