Populating List Boxes

The Activity, Activity Type, and Group form views have drop-down list boxes and the Group Membership form has list boxes. The list boxes on each form are populated in a slightly different way; in some forms, one XML Data Source Object populates multiple list boxes and in other forms, multiple XML DSOs are used. The following table describes the list boxes in the each of the PT application's form views.

HTML file Number of list box controls Topic Number of XML DSOs Async property value
Activity.htm Four drop-down list boxes In Activity.htm 1 FALSE
ActivityType.htm Two drop-down list boxes In ActivityType.htm 1 FALSE
Group.htm Three drop-down list boxes In Group.htm 2 TRUE*
PersonGroup.htm Two list boxes In PersonGroup.htm 2 TRUE*

*TRUE is the default value.

In Activity.htm

Activity.htm instantiates one XML DSO for four list boxes. The following code illustrate this process:

<OBJECT classid=clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39 height=0 id=xmldso_dd width=0 VIEWASTEXT=""></OBJECT>

The PT application uses this XML DSO to load each drop-down list box separately on the Activity form view. Because the lists are loaded in sequence, the Async property must be set to FALSE to allow each list to be populated with data. This approach delivers slower performance than the approach that PersonGroup.htm describes. The following code from Activity.js runs when the form is first loaded:

var xmldoc=xmldso_dd.XMLDocument;
xmldoc.async=false;

For the Location drop-down list box:

xmldoc.load('../Scripts/viewData.asp?tableName=location&fieldList=LocationId,Name&sortBy=Name');
copyToSel(xmldoc.documentElement,document.frmActivity.LocationId);

For the Grade Scale drop-down list box:

xmldoc.load('../Scripts/viewData.asp?tableName=gradeScale&fieldList=gradeScaleId,Name&sortBy=Name');
copyToSel(xmldoc.documentElement,document.frmActivity.GradeScaleId);

For the Activity Type drop-down list box:

xmldoc.load('../Scripts/viewData.asp?tableName=activityType&fieldList=activityTypeId,Name&sortBy=Name');
copyToSel(xmldoc.documentElement,document.frmActivity.ActivityTypeId);

For the Group drop-down list box:

xmldoc.load('../Scripts/viewData.asp?tableName=group&fieldList=groupId,Name&sortBy=Name');
copyToSel(xmldoc.documentElement,document.frmActivity.GroupId);

In ActivityType.htm

ActivityType.htm instantiates one XML DSO that populates the Grade Scale drop-down list box. The following code illustrates this process:

<OBJECT classid=clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39 height=0 id=xmldso_gs 

The following code from ActivityType.js runs when the form is first loaded. It is identical to the code in Activity.htm and Activity.js.

var xmldoc=xmldso_gs.XMLDocument;
xmldoc.async=false;
xmldoc.load('../Scripts/viewData.asp?tableName=gradeScale&fieldList=gradeScaleId,Name&sortBy=Name');
copyToSel(xmldoc.documentElement,document.frmActivityType.GradeScaleId);

The contents of the second drop-down list box on the form, penalties, are not data values. The penalties are inserted in ActivityType.htm when the localized version of the file is built. The following code illustrates this process:

<td><select name="LateType" size="1" DATAFLD="LateType" style="WIDTH: 100%" tabIndex="5" accessKey="t" onChange="setDirty()" LID="sel24">
         <option value="0" selected LID="opt24">No penalty for late scores</option>
         <option value="1" LID="opt25">Percentage of raw score</option>
         <option value="2" LID="opt26">Points off raw score</option>
         <option value="3" LID="opt27">Points lost per day late</option>
         </select></td> 

In Group.htm

Group.htm uses two XML DSOs. The Group form contains three drop-down list boxes: two for grade scales and one for locations. The content of the drop-down list boxes for grade scales is identical, so these list boxes use a common XML DSO. The drop-down list box for locations uses the other XML DSO. The following code illustrates these XML DSOs:

<OBJECT classid=clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39 height=0 
id=xmldso_loc width=0 VIEWASTEXT></OBJECT>
<OBJECT classid=clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39 height=0 id=xmldso_gs 
width=0 VIEWASTEXT></OBJECT>

The following code from Group.js runs when the form is first loaded. The updateLoc and updateGS functions call the copyToSel function.This synchronous approach provides better performance but consumes additional memory.

var xmldoc=xmldso_loc.XMLDocument;
xmldoc.ondataavailable=updateLoc;
xmldoc.load('../Scripts/viewData.asp?tableName=location&fieldList=LocationId,Name,MaxOccupancy&sortBy=Name');
xmldoc=xmldso_gs.XMLDocument;
xmldoc.ondataavailable=updateGS;
xmldoc.load('../Scripts/viewData.asp?tableName=gradeScale&sortBy=Name');

In PersonGroup.htm

PersonGroup.htm instantiates two XML DSOs. One displays existing group memberships and the other is empty. The empty XML DSO is populated when the user clicks entries in the left pane list. The following code illustrates these XML DSOs:

<OBJECT classid=clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39 codeBase="" height=0 
name=xmldso width=0 VIEWASTEXT></OBJECT>
<OBJECT classid=clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39 codeBase="" height=0 
id=XML_Data_Source_Object1 name=xmldso_info width=0 VIEWASTEXT></OBJECT>

The following code from PersonGroup.js runs when the form is first loaded:

varxml='../Scripts/viewData.asp?tableName=person&fieldList=LastName,FirstName&whereID=' + id;
xmldso_info.XMLDocument.ondataavailable = setUserName;
xmldso_info.XMLDocument.load(xml);
xml = '../Scripts/viewData.asp?procName=lw_getSchedule&personID=' + id;
xmldso.XMLDocument.ondataavailable = loaded;
xmldso.XMLDocument.load(xml);