<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.75C-CCK-MCD {C-UDP; EBM-APPLE} (Macintosh; U; PPC) [Netscape]">
<script language="JavaScript">
<!--
parent.Frame2.document.write("<HTML><BODY></BODY></HTML>")
//****** create an array called employees ***********
var employees = new Array ()
// The function defined here is a method of the record object
// "this " refers to the object ( shortcut for the pathway to the object )
function showrecords() {
var result = "<HTML><BODY><CENTER><TABLE BORDER=2>"
result += "<CAPTION ALIGN=TOP>Record data for: <B>" + this.name + "</B></CAPTION>"
result += "<TR><TD ALIGN=RIGHT>AgeField:</TD><TD>" + this.age + "</TD></TR>"
result += "<TR><TD ALIGN=RIGHT>AddressField:</TD><TD>" + this.address + "</TD></TR>"
result += "<TR><TD ALIGN=RIGHT>SexField:</TD><TD>" + this.sex + "</TD></TR>"
result += "<TR><TD ALIGN=RIGHT>HobbiesField:</TD><TD>" + this.hobbies + "</TD></TR>"
result += "<TR><TD ALIGN=RIGHT>PhoneNumber:</TD><TD>" + this.phone + "</TD></TR>"
result += "<TR><TD ALIGN=RIGHT>RecordNumber:</TD><TD>" + this.number + "</TD></TR>"
result += "</TABLE></CENTER></BODY></HTML>"
// display results in a second frame of the window
parent.Frame2.document.write(result)
parent.Frame2.document.close()
}
//************************************************
function enterdata(){
var count =prompt("how many employees","3")
for ( var i =1 ; i <= count; i++){
var thename = prompt("enter the employees name")
var theage = prompt("enter the employees age")
var theaddress = prompt("enter the employees address")
var thesex = prompt("enter the employees sex")
var thephone = prompt("enter the employees phone number")
var thehobbies = prompt("enter the employees hobbies")
var therecord = i
employees[i] = new record(thename, theage, theaddress, thesex, thephone, therecord, thehobbies)
}
}
//**************************************************
// definition of record object type;
// 'new' will create a new instance of the object and stuff parameter data into the fields // of the object
function record(name, age, address, sex, phone, number, hobbies) {
this.name = name
this.age = age
this.address = address
this.sex = sex
this.phone = phone
this.number = number
this.hobbies = hobbies
this.showrecords = showrecords
// make showrecords() function a method of the record object
}
function doDisplay() {
recnumber =prompt ( "What record number do you want?" , "2")
eval("employees[recnumber]" + ".showrecords()")
}
//-->
</script></head>
<body text="#330066" bgcolor="#ffffff" link="#3300cc" vlink="#330066" alink="#33ff33">
<center>
<h5>
<font color="#1a0aff"><font size="+3">The Database builder</font></font></h5></center>
<font face="Times New Roman,Times"><font size="+2">A program for entering
and viewing employee records.</font></font>
<br><font face="Times New Roman,Times"><font size="+2">When you press the
[enter data] button you will be asked</font></font>
<br><font face="Times New Roman,Times"><font size="+2">for the number of
employee records you wish to create.</font></font>
<br><font face="Times New Roman,Times"><font size="+2">Each record consists
of Name, Age, address, sex, and</font></font>
<br><font face="Times New Roman,Times"><font size="+2">phone number fields.
The default number of records is 3.</font></font>
<p><font size="+2">Q1. Modify the script to include a hobbies field in the
record and ..</font><font size="+2"></font>
</p><p><font size="+2">Q2. Change the HTML display the frames side by side not
one above the other.</font>
</p><p></p><form>
<font color="#ff0000"><big>This link will give you some ideas about
the way in which your programs can validate ( check for accuracy and
completion) any data entered by a user. this is not neccessary at
this stage but will be expected later in your projects</big></font><br>
<br>
<a href="http://www.elated.com/tutorials/programming/javascript/form_validation/">http://www.elated.com/tutorials/programming/javascript/form_validation/</a><br>
<br>Enter data : <input type="button" name="button1" value=" Enter data" onclick="enterdata()">View
the data: <input type="button" name="button2" value=" view data" onclick="doDisplay()">
<br></form>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body></html>