Complete Example of Using the employee, client, and project Objects : Objects Object Oriented « Language Basics « JavaScript DHTML





Complete Example of Using the employee, client, and project Objects

 

<html>
<head>
  <title>Using the book object</title>
  <script type="text/javascript">
  <!--
  function employee(FirstName, LastName, HomePhone, Ext, EmailAddress, project) {
    this.FirstName = FirstName;
    this.LastName = LastName;
    this.HomePhone = HomePhone;
    this.Ext = Ext;
    this.EmailAddress = EmailAddress;
    this.Project = project;
    this.showSummaryInfo = summaryInfo;
  }
   
  function summaryInfo() {
    objWindow = window.open("", "", "width=600,height=400");
    objWindow.document.write("<html><body>");
    objWindow.document.write("<h1>Employee Summary Information Sheet</h1>");
    objWindow.document.write("<h2>" + this.FirstName + " " + this.LastName
                             + "</h2>");
    objWindow.document.write("<p><em><Sstrong>Contact Information</strong></em></p>");
    objWindow.document.write("<p>Home Phone: " + this.HomePhone + "</p>");
    objWindow.document.write("<p>Ext.: " + this.Ext + "</p>");
    objWindow.document.write("<p>Email: " + this.EmailAddress + "</p>");
    objWindow.document.write("<p><em><strong>Project Information</strong></em></p>");
    objWindow.document.write("<p>Current Project: " + this.project.ProjectName+ "</p>");
    objWindow.document.write("<p>Client: " + this.Project.Client.ClientName + "</p>");
    objWindow.document.write("<p>Client: " + this.Project.Client.Address + "</p>");
    objWindow.document.write("<p>Client: " + this.Project.Client.City + ", " +
                        this.Project.Client.State + " " + this.Project.Client.Zip + "</p>");    objWindow.document.write("<p>Development Tool Used: " + this.Project.DevTool
                        + "</p>");
    objWindow.document.write("</body></html>");
    objWindow.document.close();
  }
   
  function project(ProjectName, client, DevTool) {
    this.ProjectName = ProjectName;
    this.Client = client;
    this.DevTool = DevTool;
  }
   
  function client(ClientName, Address, City, State, Zip) {
    this.ClientName = ClientName;
    this.Address = Address;
    this.City = City;
    this.State = State;
    this.Zip = Zip;
  }
   
  //-->
  </script>
</head>
<body>
  <script type="text/javascript">
  <!--
  CoastTech = new client("client Name", "100 street", "City","State", "11111");
  Coastal = new project("projectl01", CoastTech, "JavaScript");
  Allen = new employee("A", "B", "111/555-1111", "100","a@a.com", "Coastal");
  Allen.showSummaryInfo();
  //-->
  </script>
</body>
</html>

           
         
  










Related examples in the same category

1.Object utility: create, parse and profile
2.Define Object, use its instance
3.Define and use object
4. Creating an Object and Using Object Instance Properties and Methods
5. Object-Oriented Planetary Data Presentation
6.The Book Object Definition
7.Source Code for the showBook() Example
8.Using the Book Object Constructor
9.Creating Objects Dynamically
10.Object to array
11.Utility class for JavaScript class definition
12.Create an object and add attributes
13.Use for in loop to display all attributes from an object
14.Display the properties from an object one by one
15.An object and its constructor
16.Use function as the object constructor