Student Enrollment
Student Enrollment Records Layout
Field 1 |
Field 2 |
Field 3 |
Field 4 |
Field 5 |
Field 6 |
Field 7 |
Field 8 |
Field 9 |
Student Number |
Student Name |
Address |
Zip Code |
Gender |
Faculty or Student |
Attendance |
Age |
Course Number |
Using the Student Enrollment Records
- The records are made available to your programs with this function:
openStudentEnrollmentRecords();
- The function returns the records so you need to store them in a variable:
| // using the open function
let studentRecords;
studentRecords = openStudentEnrollmentRecords();
|
- After the openStudentEnrollmentRecords() function has been run you have access to the first record's data. You will retrieve each part of one record with a different function. Here are the functions:
studentRecords.getStudentNumber();
studentRecords.getStudentName();
studentRecords.getStudentAddress();
studentRecords.getStudentZipCode();
studentRecords.getStudentGender();
studentRecords.getFacultyStudentStatus();
studentRecords.getStudentAttendance();
studentRecords.getStudentAge();
studentRecords.getStudentCourseNumber();
-
Notice that you need to have "studentRecords." in front of each of the functions.
-
When you want to read the next record you use the following function. It will make the next record available and you then use the above functions to retrieve the data. This function returns true
if there was a next record and false
if the end of the record set has been reached.
studentRecords.readNextRecord();
Example Usage
Here's an example of how the Student Enrollment Records are used.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 | /*
This is the JavaScript code for
"Student Enrolment Records" File: /unit5/studentEnrollmentRecords.html
*/
function studentEnrollmentRecords() {
"use strict";
// Declare Variables
let currentNumber;
let currentName;
let currentAddress;
let currentZipCode;
let currentGender;
let currentFacultyStudent;
let currentStudentAttendance;
let currentAge;
let currentCourseNumber;
let outputTable;
let outputRows;
let studentRecords;
// Build table header
outputRows = "<tr><th>Student Number</th>"
+ "<th>Student Name</th>"
+ "<th>Address</th>"
+ "<th>Zip Code</th>"
+ "<th>Gender</th>"
+ "<th>Faculty/Student</th>"
+ "<th>Attendance</th>"
+ "<th>Age</th>"
+ "<th>Course Number</th></tr>";
// Get the HTML output table so we can add rows
outputTable = document.getElementById("outputTable");
// Open the Student Enrollment Records and make them
// available to the script
studentRecords = openStudentEnrollmentRecords();
// Test to see if there is a next record and then output it
while (studentRecords.readNextRecord()) {
currentNumber = studentRecords.getStudentNumber();
currentName = studentRecords.getStudentName();
currentAddress = studentRecords.getStudentAddress();
currentZipCode = studentRecords.getStudentZipCode();
currentGender = studentRecords.getStudentGender();
currentFacultyStudent = studentRecords.getFacultyStudentStatus();
currentStudentAttendance = studentRecords.getStudentAttendance();
currentAge = studentRecords.getStudentAge();
currentCourseNumber = studentRecords.getStudentCourseNumber();
// Generate an HTML table row for this student
outputRows += "<tr><td>"
+ currentNumber
+ "</td><td>"
+ currentName
+ "</td><td>"
+ currentAddress
+ "</td><td>"
+ currentZipCode
+ "</td><td>"
+ currentGender
+ "</td><td>"
+ currentFacultyStudent
+ "</td><td>"
+ currentStudentAttendance
+ "</td><td>"
+ currentAge
+ "</td><td>"
+ currentCourseNumber
+ "</td></tr>";
}
// Append the generated rows to the HTML table
outputTable.innerHTML += outputRows;
}
|
Student Enrollment Record Data