Complete Example of Using the employee, client, and project Objects : Objects Object Oriented : Language Basics : JavaScript DHTML examples (example source code) Organized by topic

JavaScript DHTML
C++
PHP
JavaScript DHTML Home »  Language Basics   » [  Objects Object Oriented  ]   
 



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

Please note that some example is only working under IE or Firefox.


/*
JavaScript Unleashed, Third Edition
by Richard Wagner and R. Allen Wyke 

ISBN: 067231763X
Publisher Sams CopyRight 2000

*/


<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("Coastal Techonology""100 Beacon Hill""Boston",
                         "MA""01220");
  Coastal = new project("Coastal01", CoastTech, "JavaScript");
  Allen = new employee("Allen""Wyke""617/555-1212""100",
                       "[email protected]""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 definitionHas Download File








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.