• No results found

Programming The World Wide Web Sebesta Robert Instructor Solution

N/A
N/A
Protected

Academic year: 2021

Share "Programming The World Wide Web Sebesta Robert Instructor Solution"

Copied!
80
0
0

Loading.... (view fulltext now)

Full text

(1)

Instructor's Resource Manual

to

Programming the World Wide Web

Seventh Edition

(2)

Preface

It is difficult to overestimate the effect the World Wide Web has had on the day-to-day lives of people, at least those in the developed countries. In fewer than 20 years, we have learned to use the Web for a myriad of disparate tasks, ranging from the mundane task of shopping for airline tickets to the crucial early-morning gathering of business news for a high-stakes day trader.

The speed at which millions of Web sites appeared in the last two decades would seem to indicate that the technologies used to build them were sitting on the shelf, fully developed and ready to use, even before the Web appeared. Also, one might guess that the tens of thousands of people who built those sites were sitting around unemployed, waiting for an opportunity and already possessing the knowledge and abilities required to carry out this mammoth construction task when it appeared. Neither of these was true. The need for new technologies was quickly filled by a large number of entrepreneurs, some at existing companies and some who started new companies. A large part of the programmer need was filled, at least to the extent to which it was filled, by new programmers, some straight from high school. Many, however, were previously employed by other sectors of the software development industry. All of them had to learn to use new languages and technologies.

A visit to a bookstore, either a bricks-and-mortar store or a Web site, will turn up a large variety of books on Web technologies aimed at the practicing professional. One difficulty encountered by those teaching courses in Web programming technologies in colleges is the lack of textbooks that are targeted to their needs. Most of the books that discuss Web programming were written

(3)

students. One major difference between an academic book and a professional book lies in the assumptions made by the author about the prior knowledge and experience of the audience. On the one hand, the backgrounds of professionals vary widely, making it difficult to assume much of anything. On the other hand, a book written for junior computer science majors can make some definite assumptions about the background of the reader.

This book is aimed at college students, not necessarily only computer science majors, but anyone who has taken at least two courses in programming. Although students are the primary target, the book is also useful for professional programmers who wish to learn Web programming.

The goal of the book is to provide the reader with a comprehensive introduction to the programming tools and skills required to build and maintain server sites on the Web. A wide variety of technologies are used in the construction of a Web site. There are now many books available for professionals that focus on these technologies. For example, there are dozens of books that specifically address only HTML. The same is true for at least a half-dozen other Web technologies. This book provides an overview of how the Web works, as well as descriptions of many of the most widely used Web technologies.

The first six editions of the book were used to teach a junior-level Web programming course at the University of Colorado at Colorado Springs. The challenge for students in the course is to learn to use several different programming languages and technologies in one semester. A heavy load of programming exercises is essential to the success of the course. Students in the course build a basic, static Web site, using only HTML as the first assignment. Throughout the remainder of the semester, they add features to their site as the new technologies are discussed in the course. Our students’ prior course work in Java and data structures, as well as C and assembly language, is helpful, as is the fact that many of them have learned some HTML on their own before taking the course.

The most important prerequisite to the material of this book is a solid background in programming in some language that supports object-oriented programming. It is helpful to have some knowledge of a second programming language and a bit of UNIX, particularly if a UNIX-based Web server is used for the course. Familiarity with a second language makes learning the new languages easier.

Table of Contents

The book is organized into three parts: the introduction (Chapter 1), client-side technologies (Chapters 2–8), and server-side technologies (Chapters 9–15).

Chapter 1 lays the groundwork for the rest of the book. A few fundamentals are introduced, including the history and nature of the Internet, the World Wide

(4)

Chapter 1 are brief overviews of the most important topics of the rest of the book.

Chapter 2 provides an introduction to HTML, including images, links, lists, tables, and forms. Small examples are used to illustrate many of the HTML elements that are discussed in this chapter. A discussion of the parts of HTML5 that are now widely supported is included.

The topic of Chapter 3 is cascading style sheets, which provide the standard way of imposing style on the content specified in HTML tags. Because of the size and complexity of the topic, the chapter does not cover all of the aspects of style sheets. The topics discussed are levels of style sheets, style specification formats, selector formats, property values, and color. Among the properties covered are those for fonts, lists, and margins. Small examples are used to illustrate the subjects that are discussed.

Chapter 4 introduces the core of JavaScript, a powerful language that could be used for a variety of different applications. Our interest, of course, is its use in Web programming. Although JavaScript has become a large and complex language, we use the student’s knowledge of programming in other languages to leverage the discussion, thereby providing a useful introduction to the language in a manageably small number of pages. Topics covered are the object model of JavaScript, its control statements, objects, arrays, functions, constructors, and pattern matching.

Chapter 5 discusses some of the features of JavaScript that are related to HTML documents. Included is the use of the basic and DOM 2 event and event-handling model, which can be used in conjunction with some of the elements of HTML documents. The HTML5 canvas element is introduced.

One of the interesting applications of JavaScript is building dynamic HTML documents with the Document Object Model (DOM). Chapter 6 provides descriptions of a collection of some of the changes that can be made to documents with the use of JavaScript and the DOM. Included are positioning elements; moving elements; changing the visibility of elements; changing the color, style, and size of text; changing the content of tags; changing the stacking order of overlapped elements; moving elements slowly; and dragging and dropping elements.

Chapter 7 presents an introduction to XML, which provides the means to design topic-specific markup languages that can be shared among users with common interests. Included are the syntax and document structure used by XML, data type definitions, namespaces, XML schemas, and the display of XML documents with both cascading style sheets and XML transformations. Also included is an introduction to Web services and XML processors.

Chapter 8 introduces the Flash authoring environment, which is used to create a wide variety of visual and audio presentations—in particular, those that include animation. A series of examples is used to illustrate the development processes, including drawing figures, creating text, using color, creating motion and shape animations, adding sound tracks to presentations, and designing

(5)

Chapter 9 introduces PHP, a server-side scripting language that enjoys wide popularity, especially as a database access language for Web applications. The basics of the language are discussed, as well as the use of cookies and session tracking. The use of PHP as a Web database access language is covered in Chapter 13.

Chapter 10 introduces Ajax, the relatively recent technology that is used to build Web applications with extensive user interactions that are more efficient than those same applications if they do not use Ajax. In addition to a thorough introduction to the concept and implementation of Ajax interactions, the chapter includes discussions of return document forms, Ajax toolkits, and Ajax security. Several examples are used to illustrate approaches to using Ajax.

Java Web software is discussed in Chapter 11. The chapter introduces the mechanisms for building Java servlets and gives several examples of how servlets can be used to present interactive Web documents. The NetBeans framework is introduced and used throughout the chapter. Support for cookies in servlets is presented and illustrated with an example. Then JSP is introduced through a series of examples, including the use of code-behind files. This discussion is followed by an examination of JavaBeans and JavaServer Faces, along with examples to illustrate their use.

Chapter 12 is an introduction to ASP.NET, although it begins with a brief introduction to the .NET Framework and C#. ASP.NET Web controls and some of the events they can raise and how those events can be handled are among the topics discussed in this chapter. ASP.NET AJAX is also discussed. Finally, constructing Web services with ASP.NET is introduced. Visual Studio is introduced and used to develop all ASP.NET examples.

Chapter 13 provides an introduction to database access through the Web. This chapter includes a brief discussion of the nature of relational databases, architectures for database access, the structured query language (SQL), and the free database system MySQL. Then, three approaches to Web access to databases are discussed: using PHP, using Java JDBC, and using ASP.NET. All three are illustrated with complete examples. All of the program examples in the chapter use MySQL.

Chapter 14 introduces the Ruby programming language. Included are the scalar types and their operations, control statements, arrays, hashes, methods, classes, code blocks and iterators, and pattern matching. There is, of course, much more to Ruby, but the chapter includes sufficient material to allow the student to use Ruby for building simple programs and Rails applications.

Chapter 15 introduces the Rails framework, designed to make the construction of Web applications relatively quick and easy. Covered are simple document requests, both static and dynamic, and applications that use databases, including the use of scaffolding.

Appendix A introduces Java to those who have experience with C++ and object-oriented programming, but who do not know Java. Such students can learn enough of the language from this appendix to allow them to understand the

(6)

Appendix B is a list of 140 named colors, along with their hexadecimal codings.

Support Materials

Supplements for the book are available at Addison-Wesley’s Web site www.pearsonhighered.com/cssupport. Support materials available to all readers of this book include

• A set of lecture notes in the form of PowerPoint files. The notes were developed to be the basis for class lectures on the book material.

• Code for example programs •

• A Word document listing errors found in the book

Additional support material, including solutions to selected exercises and figures from the book, are available only to instructors adopting this textbook for classroom use. Contact your school’s Pearson Education representative for information on obtaining access to this material, or visit pearsonhighered.com.

Software Availability

Most of the software systems described in this book are available free to students. These systems include browsers that provide interpreters for JavaScript and parsers for XML. Also, PHP, Ruby, and Java language processors, as well as the Rails framework, Java class libraries to support servlets, and Java JDBC, are available and free. ASP.NET is supported by the .NET software available from Microsoft. The Visual Web Developer 2010, a noncommercial version of Visual Studio, is available free from Microsoft. A free 30-day trial version of the Flash development environment is available from Adobe.

Differences between the Sixth Edition

and the Seventh Edition

The seventh edition of this book differs significantly from the sixth.

The markup documents in the whole book were modified to reflect the change from XHTML 1.0 to HTML5. However, the XHTML syntax rules are used in all example documents.

Chapter 2 was revised to update the discussion for HTML, rather than XHTML 1.0. A section was added on some of the new elements in HTML5.

(7)

Sections on contextual selectors and text spacing were removed from Chapter 3. All CSS sizes used in this chapter (and the remainder of the book) were changed from points to em.

A discussion of the HTML5 canvas element was added to Chapter 5.

Chapter 8 was revised to cover Flash 5.5, rather than Flash 4. Also, a section on importing graphic figures was added.

Chapter 11 was revised to use version 7 of the NetBeans development system, rather than 6.7. This required numerous changes.

Chapter 12 was revised to use Visual Studio 2010.

In Chapter 13, the discussion of the PHP/MySQL functions was revised to reflect the new version of these functions. The PHP/MySQL examples also were updated to use these new functions. The section on JDBC/MySQL was updated to use NetBeans 7.

Chapter 15 was revised to discuss the use of Rails 3.1 rather than Rails 2.4. This required extensive changes. Also, the discussion of Instant Rails was dropped, as was the section on Rails with Ajax.

Throughout the book, numerous small changes were made to improve the correctness and clarity of the material.

(8)

Table of Contents

Preface xiii

1

Fundamentals 00

1.1 A Brief Introduction to the Internet 00 1.2 The World Wide Web 00

1.3 Web Browsers 00 1.4 Web Servers 00

1.5 Uniform Resource Locators 00

1.6 Multipurpose Internet Mail Extensions 00 1.7 The Hypertext Transfer Protocol 00 1.8 Security 00

1.9 The Web Programmer’s Toolbox 00

Summary 00

Review Questions 00 Exercises 00

2

Introduction to HTML/XHTML 00

2.1 Origins and Evolution of HTML and XHTML 00 2.2 Basic Syntax 00

2.3 Standard HTML Document Structure 00 2.4 Basic Text Markup 00

2.5 Images 00 2.6 Hypertext Links 00 2.7 Lists 00 2.8 Tables 00 2.9 Forms 00 2.10 HTML5

(9)

Summary 00

Review Questions 00 Exercises 00

3

Cascading Style Sheets 00 3.1 Introduction 00

3.2 Levels of Style Sheets 00 3.3 Style Specification Formats 00 3.4 Selector Forms 00

3.5 Property Value Forms 00 3.6 Font Properties 000 3.7 List Properties 000 3.8 Alignment of Text 000 3.9 Color 000

3.10 The Box Model 000 3.11 Background Images 000

3.12 The <span> and <div> Tags 000 3.13 Conflict Resolution 000

Summary 000

Review Questions 000 Exercises 000

4

The Basics of JavaScript 000 4.1 Overview of JavaScript 000

4.2 Object Orientation and JavaScript 000 4.3 General Syntactic Characteristics 000 4.4 Primitives, Operations, and Expressions 137 4.5 Screen Output and Keyboard Input 000 4.6 Control Statements 000

(10)

4.8 Arrays 000 4.9 Functions 000 4.10 An Example 000 4.11 Constructors 000

4.12 Pattern Matching Using Regular Expressions 000 4.13 Another Example 000

4.14 Errors in Scripts 000

Summary 000

Review Questions 000 Exercises 000

5

JavaScript and HTML Documents 000

5.1 The JavaScript Execution Environment 000 5.2 The Document Object Model 000

5.3 Element Access in JavaScript 000 5.4 Events and Event Handling 000

5.5 Handling Events from Body Elements 000 5.6 Handling Events from Button Elements 000

5.7 Handling Events from Text Box and Password Elements 000 5.8 The DOM 2 Event Model 000

5.9 The canvas Element

5.10 The navigator Object 000

5.11 DOM Tree Traversal and Modification 000

Summary 000

Review Questions 000 Exercises 000

6

Dynamic Documents with JavaScript 000 6.1 Introduction 000

(11)

6.3 Moving Elements 234 6.4 Element Visibility 000

6.5 Changing Colors and Fonts 000 6.6 Dynamic Content 000

6.7 Stacking Elements 000

6.8 Locating the Mouse Cursor 000 6.9 Reacting to a Mouse Click 000 6.10 Slow Movement of Elements 000 6.11 Dragging and Dropping Elements 000

Summary 000 Review Questions 000 Exercises 000

7

Introduction to XML 000 7.1 Introduction 000 7.2 The Syntax of XML 000 7.3 XML Document Structure 000 7.4 Document Type Definitions 000 7.5 Namespaces 000

7.6 XML Schemas 000

7.7 Displaying Raw XML Documents 000 7.8 Displaying XML Documents with CSS 000 7.9 XSLT Style Sheets 000

7.10 XML Processors 000 7.11 Web Services 000

(12)

Review Questions 000 Exercises 000

8

Introduction to Flash 000

8.1 Origins and Uses of Flash 000

8.2 A First Look at the Flash Authoring Environment 000 8.3 Drawing Tools 000

8.4 Static Graphics 000 8.5 Animation and Sound 000 8.6 User Interactions 000

Summary 000

Review Questions 000 Exercises 000

9

Introduction to PHP 000

9.1 Origins and Uses of PHP 000 9.2 Overview of PHP 000

9.3 General Syntactic Characteristics 000 9.4 Primitives, Operations, and Expressions 000 9.5 Output 000 9.6 Control Statements 000 9.7 Arrays 000 9.8 Functions 000 9.9 Pattern Matching 000 9.10 Form Handling 000 9.11 Cookies 000 9.12 Session Tracking 000

(13)

Review Questions 000 Exercises 000

10

Introduction to Ajax 000 10.1 Overview of Ajax 000 10.2 The Basics of Ajax 000 10.3 Return Document Forms 000 10.4 Ajax Toolkits 000

10.5 Security and Ajax 000

Summary 000

Review Questions 000 Exercises 000

11

Java Web Software 000

11.1 Introduction to Servlets 000

11.2 The NetBeans Integrated Development Environment 000 11.3 A Survey Example 000

11.4 Storing Information on Clients 000 11.5 JavaServer Pages 000

11.6 JavaBeans 000

11.7 Model-View-Controller Application Architecture 000 11.8 JavaServer Faces 000

Summary 000

Review Questions 000 Exercises 000

12

Introduction to ASP.NET 000

12.1 Overview of the .NET Framework 000 12.2 A Bit of C# 000

(14)

12.3 Introduction to ASP.NET 000 12.4 ASP.NET Controls 000 12.5 ASP.NET AJAX 000 12.6 Web Services 000 Summary 000 Review Questions 000 Exercises 000

13

Database Access through the Web 000 13.1 Relational Databases 000

13.2 An Introduction to the Structured Query Language 000 13.3 Architectures for Database Access 000

13.4 The MySQL Database System 000

13.5 Database Access with PHP and MySQL 000 13.6 Database Access with JDBC and MySQL 000 13.7 Database Access with ASP.NET and MySQL 000

Summary 000

Review Questions 000 Exercises 000

14

Introduction to Ruby 000

14.1 Origins and Uses of Ruby 000

14.2 Scalar Types and Their Operations 000 14.3 Simple Input and Output 000

14.4 Control Statements 000 14.5 Fundamentals of Arrays 000 14.6 Hashes 000

14.7 Methods 000 14.8 Classes 000

(15)

14.10Pattern Matching 000 Summary 000 Review Questions 000 Exercises 000

15

Introduction to Rails 000 15.1 Overview of Rails 000 15.2 Document Requests 000

15.3 Rails Applications with Databases 000

Summary 000

Review Questions 000 Exercises 000

Appendix A Introduction to Java 000 Appendix B Named Colors 000 Index 000

(16)

Solutions to Selected Exercises

Chapter 2

Exercise 2.1

<!DOCTYPE html> <!-- e2_1.html

This is a solution to Exercise 2.1 -->

<html lang = "en"> <head>

<title> Exercise 2.1 </title> <meta charset = "utf-8" /> </head> <body> <h2> Ruper B. Baggins </h2> <p> 1321 Causeway Circle <br /> Middle, Earth <br /> [email protected]<br /> </p> <hr /> <h3> Bush Watcher </h3> <p>

<em> Forest Keepers, Limited </em> <br /> 14 Cranberry Way <br />

Middle, Earth <br />

<strong> (no web site yet) </strong> </p> </body> </html>

Exercise 2.3

<!DOCTYPE html"> <!-- e2_3.html

This is a solution to Exercise 2.3 -->

<html lang = "en"> <head>

<title> Exercise 2.3 </title> <meta charset = "utf-8" /> </head>

(17)

<h2> Ruper B. Baggins </h2> <p>

1321 Causeway Circle <br /> Middle, Earth <br />

[email protected]<br /><br />

<a href = "e2_31.html"> Mr. Baggins' Background </a> </p>

<hr />

<h3> Bush Watcher </h3> <p>

<em> Forest Keepers, Limited </em> <br /> 14 Cranberry Way <br />

Middle, Earth <br />

<strong> (no web site yet) </strong> </p>

</body> </html>

<!DOCTYPE html> <!-- e2_31.html

This is part of the solution to Exercise 2.3 (The second document for the background info) -->

<html lang = "en"> <head>

<title> Exercise 2.3 (background) </title> <meta charset = "utf-8" />

</head> <body> <p>

Although we share the same family name, I am not in any way related to the famous (or is it infamous) adventurer, Bilbo. I have a lovely wife, Elvira, and two grown children, Max and Miriam. Max has chosen to follow me in my profession, which is described below. Miriam is a beekeeper for the town bookkeeper, who keeps bees as a second job.

</p> <p>

I am employed by Forest Keepers, Limited. My job, as I understand it, is to keep an eye on the 4 acres of wild cranberries that grow in the swamp at the edge of the village forest. I am required to file a daily report, in triplicate, on the condition of the cranberry bushes. To accomplish my task, I walk by and inspect

every cranberry bush in the swamp every workday. My employer provides me with wading boots for my job. I pick up the boots at the office every weekday morning and turn them back in, after a thorough cleaning, after each workday.

</p> </body> </html>

Exercise 2.4

(18)

<!-- e2_4.html

A solution to Exercise 2.4 - an unordered list -->

<html lang = "en"> <head>

<title> Unordered List </title> <meta charset = "utf-8" /> </head>

<body>

<h3> Grocery List </h3> <ul>

<li> milk - 2%, 2 gallons </li> <li> bread - butter top wheat </li> <li> cheddar cheese - sharp, 1 lb. </li> <li> soup - vegetable beef, 3 cans </li> <li> hamburger - 80% fat free, 2 lbs. </li>

<li> orange juice - not from concentrate, 1/2 gallon </li> <li> eggs - large, 1 dozen </li>

</ul> </body> </html>

Exercise 2.8

<!DOCTYPE html> <!-- e2_8.html

A solution to Exercise 2.8 - a nested, ordered list -->

<html lang = "en"> <head>

<title> An Ordered List </title> <meta charset = "utf-8" />

</head> <body>

<h3> My Uncles, Aunts, and Cousins </h3> <ol>

<li> Violet Vinelli (my mother) </li> <li> Frederick Vinelli

<ol>

<li> Mary Vinelli </li> <li> Betty Ann Boop </li> <li> Bob Vinelli </li> <li> Roger Vinelli </li> </ol>

</li>

<li> Maxine Robinson <ol>

<li> John Robinson </li> <li> Patty Robinson </li> <li> Lucille Robinson </li> </ol>

</li>

<li> Thomas Vinelli <ol>

(19)

<li> Alison MacKinsey </li> <li> Alton Vinelli </li> </ol>

</li> </ol> <ol>

<li> Albert Alphonso (my father) </li> <li> Herbert Alphonso

<ol>

<li> Louise Alphonso </li> <li> Pam Alphonso </li> <li> Fred Alphonso </li> </ol>

</li>

<li> Ann Marie Predicate <ol>

<li> George Predicate </li> <li> Michael Predicate </li> <li> Darcie Predicate </li> </ol>

</li>

<li> Ferdinand Alphonso <ol>

<li> Noah Alphonso </li> <li> Leah Alphonso </li> <li> Jo Alphonso </li> </ol> </li> </ol> </body> </html>

Exercise 2.9

<!DOCTYPE html> <!-- e2_9.html

A solution to Exercise 2.9 - a simple table -->

<html lang = "en"> <head>

<title> A simple table </title> <meta charset = "utf-8" /> </head>

<body> <table>

<caption> Trees </caption> <tr> <th> </th> <th> Pine </th> <th> Maple </th> <th> Oak </th> <th> Fir </th> </tr> <tr>

(20)

<th> Average Height (feet) </th> <td> 55 </td> <td> 50 </td> <td> 50 </td> <td> 65 </td> </tr> <tr>

<th> Average Width (inches) </th> <td> 18 </td> <td> 26 </td> <td> 24 </td> <td> 28 </td> </tr> <tr>

<th> Typical Lifespan (years) </th> <td> 150 </td> <td> 230 </td> <td> 310 </td> <td> 135 </td> </tr> <tr> <th> Leaf Type </th> <td> Long needles </td> <td> Broadleaf </td> <td> Split leaf </td> <td> Short needles </td> </tr> </table> </body> </html>

Exercise 2.10

<!DOCTYPE html> <!-- e2_10.html

A solution to Exercise 2.10 - a simple table -->

<html lang = "en"> <head>

<title> A simple table </title> <meta charset = "utf-8" /> </head>

<body> <table>

<caption> Tree Characteristics </caption> <tr> <td rowspan = "2" colspan = "2"> </td> <th colspan = "4"> Tree </th> </tr> <tr> <th> Pine </th> <th> Maple </th> <th> Oak </th> <th> Fir </th>

(21)

</tr> <tr>

<th rowspan = "4"> Characteristic </th> <th> Average Height (feet) </th>

<td> 55 </td> <td> 50 </td> <td> 50 </td> <td> 65 </td> </tr> <tr>

<th> Average Width (inches) </th> <td> 18 </td> <td> 26 </td> <td> 24 </td> <td> 28 </td> </tr> <tr>

<th> Typical Lifespan (years) </th> <td> 150 </td> <td> 230 </td> <td> 310 </td> <td> 135 </td> </tr> <tr> <th> Leaf Type </th> <td> Long needles </td> <td> Broadleaf </td> <td> Split leaf </td> <td> Short needles </td> </tr> </table> </body> </html>

Exercise 2.17

<!DOCTYPE html> <!-- e2_17.html

A solution to Exercise 2.17 - a revision of 2.8 with headers and footers

-->

<html lang = "en"> <head>

<title> An Ordered List </title> <meta charset = "utf-8" />

</head> <body> <header>

<h2> Bob's Relatives </h2>

<h3> (Uncles, Aunts, and Cousins) </h3> </header>

<ol>

<li> Violet Vinelli (my mother) </li> <li> Frederick Vinelli

(22)

<li> Mary Vinelli </li> <li> Betty Ann Boop </li> <li> Bob Vinelli </li> <li> Roger Vinelli </li> </ol>

</li>

<li> Maxine Robinson <ol>

<li> John Robinson </li> <li> Patty Robinson </li> <li> Lucille Robinson </li> </ol>

</li>

<li> Thomas Vinelli <ol>

<li> Albert Vinelli </li> <li> Alison MacKinsey </li> <li> Alton Vinelli </li> </ol>

</li> </ol> <ol>

<li> Albert Alphonso (my father) </li> <li> Herbert Alphonso

<ol>

<li> Louise Alphonso </li> <li> Pam Alphonso </li> <li> Fred Alphonso </li> </ol>

</li>

<li> Ann Marie Predicate <ol>

<li> George Predicate </li> <li> Michael Predicate </li> <li> Darcie Predicate </li> </ol>

</li>

<li> Ferdinand Alphonso <ol>

<li> Noah Alphonso </li> <li> Leah Alphonso </li> <li> Jo Alphonso </li> </ol>

</li> </ol> <article>

Family information can be neatly organized using any of several available software systems. These systems provide the capability of producing tree-structured drawings of the organization of a family. </article> <footer> <h4> As of January, 2012 <h4> </footer> </body>

(23)

Chapter 3

Exercise 3.1

/* Book Layout Style Sheet */

h1 {font: bold 2em Helvetica 'Times New Roman'} h2 {font: bold 1.8em Helvetica 'Times New Roman'} h3 {font: bold 1.2em Helvetica 'Times New Roman'} p {font: 1em 'Times New Roman'}

Exercise 3.2

<!DOCTYPE html> <!-- e3_2.html

A solution to Exercise 3.2 - a styled table -->

<html lang = "en"> <head>

<title> A Styled Table </title> <style type = "text/css">

<!--

td.win {font-size: 1.2em; color: red;} td.lose {font-size: 1.1em; color: blue;} -->

</style>

<meta charset = "utf-8" /> </head>

<body>

<table border = "border">

<caption style = "font-size: 18pt"> Football Scores </caption> <tr>

<th> Team </th> <th> Score </th> </tr>

<tr>

<th style = "font-family: 'Century Gothic'; font-style: italic;

color: gold;"> Colorado </th> <td class = "win"> 30 </td>

</tr> <tr>

<th style = "font-family: 'Century Gothic'; font-style: italic;

color: red;"> Nebraska </th> <td class = "lose"> 29 </td>

</tr> <tr>

<th style = "font-family: 'Century Gothic'; font-style: italic;

color: grey;"> Iowa State </th> <td class = "win"> 17 </td>

(24)

</tr> <tr>

<th style = "font-family: 'Century Gothic'; font-style: italic;

color: blue;"> Kansas </th> <td class = "lose"> 10 </td>

</tr> <tr>

<th style = "font-family: 'Century Gothic'; font-style: italic;

color: purple;"> Kansas State </th> <td class = "win"> 48 </td>

</tr> <tr>

<th style = "font-family: 'Century Gothic'; font-style: italic;

color: green;"> Missouri </th> <td class = "lose"> 13 </td> </tr> </table> </body> </html>

Exercise 3.4

<!DOCTYPE html"> <!-- e3_4.html

A solution for Exercise 3.4 - floating a text element -->

<html lang = "en"> <head>

<title> Floating a text element </title> <meta charset = "utf-8" />

</head> <body>

<p style = "float: left; width: 1.5in; margin-right: 10px; margin-bottom: 10px;" >

My airplane soars like an eagle and handles like a hummingbird.

</p> <p>

The 210 is the flagship

single-engine Cessna aircraft. Although the 210 began as a four-place aircraft, it soon acquired a third row of seats, stretching it to a six-place plane. The 210 is classified as a high-performance airplane, which means its landing gear is retractable and its engine has more than 200 horsepower. In its first model year, which was 1960, the 210 was powered by a 260-horsepower fuel-injected six-cylinder engine that displaced 471 cubic inches. The 210 is the fastest single-engine airplane ever built by Cessna.

</p> </body>

(25)

</html>

Exercise 3.6

<!DOCTYPE html> <!-- e36.html A solution to Exercise 3.6 --> <html lang = "en"> <head>

<title> Exercise 3.6 </title> <style type = "text/css">

ol {list-style-type: upper-roman;} ol ol {list-style-type: upper-alpha;} ol ol ol {list-style-type: decimal;} li.pink {color: pink}

li.blue {color: blue} li.red {color: red} </style>

<meta charset = "utf-8" /> </head>

<body>

<ol>

<li class = "pink"> Compact Cars <ol>

(26)

<ol>

<li> Hyundai Accent </li> <li> Chevrolet Cobalt </li> <li> Honda Civic </li> </ol>

</li>

<li> Four door <ol>

<li> Hyundai Accent </li> <li> Chevrolet Cobalt </li> <li> Honda Civic </li> </ol>

</li> </ol> </li>

<li class = "blue"> Midsize Cars <ol>

<li> Two door <ol>

<li> Honda Accord </li> <li> Hyundai Genesis </li> <li> Nissan Altima </li> </ol>

</li>

<li> Four door <ol>

<li> Honda Accord </li> <li> Dodge Avenger </li> <li> Ford Fusion </li> </ol>

</li> </ol> </li>

<li class = "red"> Sports Cars <ol>

<li> Coupe <ol>

<li> Jaguar XK </li> <li> Ford Mustang </li> <li> Nissan Z </li> </ol>

</li>

<li> Convertible <ol>

<li> Mazda Miata </li> <li> Ford Mustang </li> <li> Lotus Elise </li> </ol> </li> </ol> </li> </ol> </body> </html>

(27)

Exercise 3.12

<!DOCTYPE html> <!-- e312.html A solution to Exercise 3.12 --> <html lang = "en"> <head>

<title> Exercise 3.12 </title> <style type = "text/css">

dt {font-family: Courier; font-size: 1em;}

dd {font-family: 'Times New Roman'; font-size: 1.1em; font-style: italic;}

</style>

<meta charset = "utf-8" /> </head>

<body>

<h3> Single-Engine Cessna Airplanes </h3> <dl>

<dt> 152 </dt>

<dd> Two-place trainer </dd> <dt> 172 </dt>

<dd> Smaller four-place airplane </dd> <dt> 182 </dt>

<dd> Larger four-place airplane </dd> <dt> 210 </dt>

<dd> Six-place airplane - high performance </dd> </dl> </body> </html>

Chapter 4

Exercise 4.1

<!DOCTYPE html>

<!-- e4_1.html - A solution to Exercise 4.1 -->

<html lang = "en"> <head>

<title> Exercise 4.1 </title> <meta charset = "utf-8" /> </head>

<body>

<script type = "text/javascript">

<!--var number, square, cube;

document.write("Number, Square, Cube <br /><br />"); for (number = 5; number < 16; number++) {

square = number * number; cube = number * square;

(28)

document.write(number + ", " + square + ", " + cube + "<br />"); } // --> </script> </body> </html>

Exercise 4.2

<!DOCTYPE html>

<!-- e4_2.html - A solution to Exercise 4.2 -->

<html lang = "en"> <head>

<title> Exercise 4.2 </title> <meta charset = "utf-8" /> </head>

<body>

<script type = "text/javascript">

<!--var first = 1, second = 1, next, count;

document.write("First 20 Fibonacci Numbers <br/><br/>"); document.write("1 - 1 <br/> 2 - 1 <br/>");

for (count = 3; count <= 20; count++) { next = first + second;

document.write(count + " - " + next + "<br/>"); first = second; second = next; } // --> </script> </body> </html>

Exercise 4.4

<!DOCTYPE html>

<!-- e4_4.html - A solution to Exercise 4.4 -->

<html lang = "en"> <head>

<title> Exercise 4.4 </title> <meta charset = "utf-8" /> </head>

<body>

<script type = "text/javascript">

(29)

number = prompt("How many Fibonacci numbers do you want? (3-50)", ""); if (number >= 3 && number <= 50) {

document.write("First " + number + " Fibonacci Numbers <br /><br />");

document.write("1 - 1 <br/> 2 - 1 <br />"); for (count = 3; count <= number; count++) { next = first + second;

document.write(count + " - " + next + "<br />"); first = second; second = next; } } else

document.write("Error - number not in the range 3-50"); // --> </script> </body> </html>

Exercise 4.6

<!DOCTYPE html>

<!-- e4_6.html - A solution to Exercise 4.6 -->

<html lang = "en"> <head>

<title> Exercise 4.6 </title> <meta charset = "utf-8" /> </head>

<body>

<script type = "text/javascript">

<!--var first = 1, second = 1, next, count;

str = prompt("Please input your sentence", ""); var words = str.split(" ");

words = words.sort(); words_len = words.length;

for (count = 0; count < words_len; count++) document.write(words[count] + "<br/>"); // -->

</script> </body> </html>

(30)

Exercise 4.7

<!DOCTYPE html>

<!-- e4_7.html - A solution to Exercise 4.7 -->

<html lang = "en"> <head>

<title> Exercise 4.7 </title> <meta charset = "utf-8" />

<script type = "text/javascript">

// A function to compare strings for reverse alphabetic order function dec_order(a, b) { if (a > b) return -1; else if (a < b) return 1; else return 0; } // --> </script> </head> <body>

<script type = "text/javascript">

<!--var order, str, words, word_len, count; // Get the input

str = prompt("Please input your sentence", "");

order = prompt("What order? (ascending or descending)", ""); // If the order is recognized, issue an error message

if (order != "descending" && order != "ascending")

document.write("Error - order is incorrectly specified <br/>"); // Otherwise, do the sort, depending on the requested order

else {

var words = str.split(" "); if (order == "ascending") words = words.sort(); else

words = words.sort(dec_order); // Write out the results

words_len = words.length;

for (count = 0; count < words_len; count++) document.write(words[count] + "<br/>");

(31)

} // --> </script> </body> </html>

Exercise 4.9

<!DOCTYPE html>

<!-- e4_9.html - A solution to Exercise 4.9 -->

<html lang = "en"> <head>

<title> Exercise 4.9 </title> <meta charset = "utf-8" />

<script type = "text/javascript">

// Function e_names

// Parameter: an array of strings

// Returns: the number of given strings that end // in either "ie" or "y"

function e_names(names) { var len, index, count = 0; len = names.length;

// Loop to use pattern matching to produce the count for (index = 0; index < len; index++) {

position1 = names[index].search(/ie$/); position2 = names[index].search(/y$/); if (position1 + position2 > -2) count++; } return count; } // --> </script> </head> <body>

<script type = "text/javascript">

<!--// Function e_names tester

var new_names = new Array ("freddie", "bob", "mieke", "yahoo2", "georgey");

result = e_names(new_names);

document.write("The number of special names is: " + result + "<br/>"); // -->

</script> </body> </html>

(32)

Exercise 4.14

<?xml version = "1.0" encoding = "utf-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- e4_14.html - A solution to Exercise 4.14

-->

<html xmlns = "http://www.w3.org/1999/xhtml"> <head>

<title> Exercise 4.14 </title> <meta charset = "utf-8" />

<script type = "text/javascript">

var result;

// Function reverser // Parameter: a number

// Returns: the number with its digits in reverse order // Note: Math.floor must be used to get the integer part // of the division operations

function reverser(num) { var digit, position = 0;

// If the number has just one digit, that's it if (num < 10)

return num; // Get the first digit result = num % 10;

num = Math.floor(num / 10);

// Loop to produce the result for the rest do {

digit = num % 10;

result = 10 * result + digit; num = Math.floor(num / 10); } while (num >= 1); return result; } // --> </script> </head> <body>

<script type = "text/javascript">

<!--// Function reverser tester var num1 = 2468, num2 = 7; result = reverser(num1);

(33)

document.write("The reverse of 2468 is: " + result + "<br />"); result = reverser(num2);

document.write("The reverse of 7 is: " + result + "<br />"); // --> </script> </body> </html>

Chapter 5

Exercise 5.1

<!DOCTYPE html> <!-- e51.hmtl

A solution to Exercise 5.1 - events with radio buttons -->

<html lang = "en"> <head>

<title> Exercise 5.1 </title>

<script type = "text/javascript" src = "e51.js" > </script>

<meta charset = "utf-8" /> </head>

<body>

<h4> Choose your favorite color </h4> <form>

<label> <input type = "radio" name = "colorButton" value = "red"

onClick = "colorChoice('red')" /> Red </label>

<br />

<label> <input type = "radio" name = "colorButton" value = "blue"

onClick = "colorChoice('blue')" /> Blue </label>

<br />

<label> <input type = "radio" name = "colorButton" value = "green"

onClick = "colorChoice('green')" /> Green </label>

<br />

<label> <input type = "radio" name = "colorButton" value = "yellow"

onClick = "colorChoice('yellow')" /> Yellow </label>

<br />

<label> <input type = "radio" name = "colorButton" value = "orange" onClick = "colorChoice('orange')" /> Orange </label> </form> </body> </html>

// e51.js - The JavaScript solution for Exercise 5.1 //

(34)

// The event handler function to produce an alert message // about the chosen color

function colorChoice (color) { switch (color) {

case "red":

alert("Your favorite color is red"); break;

case "blue":

alert("Your favorite color is blue"); break;

case "green":

alert("Your favorite color is green"); break;

case "yellow":

alert("Your favorite color is yellow"); break;

case "orange":

alert("Your favorite color is orange"); break;

default:

alert("Error in JavaScript function colorChoice"); break; } }

Exercise 5.2

<!DOCTYPE html> <!-- e5_2.hmtl

A solution to Exercise 5.2 - events with radio buttons -->

<html lang = "en"> <head>

<title> Exercise 5.2 </title>

<script type = "text/javascript" src = "e521.js" > </script>

<meta charset = "utf-8" /> </head>

<body>

<h4> Choose your favorite color </h4> <form id = "colorsForm">

<p>

<label> <input type = "radio" name = "colorButton" value = "red" /> Red

</label> </p> <p>

<label> <input type = "radio" name = "colorButton" value = "blue" /> Blue

</label> </p><p>

<label> <input type = "radio" name = "colorButton" value = "green" /> Green

(35)

</label> </p><p>

<label> <input type = "radio" name = "colorButton" value = "yellow" /> Yellow

</label> </p><p>

<label> <input type = "radio" name = "colorButton" value = "orange" /> Orange

</label> </p> </form>

<script type = "text/javascript" src = "e522.js" > </script>

</body> </html>

// e521.js - JavaScript for the solution to Exercise 5.2 //

// The event handler function to produce an alert message // about the chosen color

function colorChoice () { var color;

// Put the DOM address of the elements array in a local variable

var radioElement = document.getElementById("colorsForm").elements; // Determine which button was pressed

for (var index = 0; index < radioElement.length; index++) { if (radioElement[index].checked) {

color = radioElement[index].value; break;

} }

// Produce an alert message about the chosen color switch (color) {

case "red":

alert("Your favorite color is red"); break;

case "blue":

alert("Your favorite color is blue"); break;

case "green":

alert("Your favorite color is green"); break;

case "yellow":

alert("Your favorite color is yellow"); break;

case "orange":

(36)

break; default:

alert("Error in JavaScript function colorChoice"); break;

} }

// e522.js - Handler registration for the solution to // Exercise 5.2

var dom = document.getElementById("colorsForm"); dom.elements[0].onclick = colorChoice; dom.elements[1].onclick = colorChoice; dom.elements[2].onclick = colorChoice; dom.elements[3].onclick = colorChoice; dom.elements[4].onclick = colorChoice;

Exercise 5.4

<!DOCTYPE html> <!-- e54.html A solution to Exercise 5.4 --> <html lang = "en"> <head>

<title> Exercise 5.4 </title>

<script type = "text/javascript" src = "e54.js" > </script>

<meta charset = "utf-8" /> </head>

<body>

<h3> Order Form </h3>

<form name = "orderForm" onSubmit = "finish()"> <p>

<label> <input type = "text" name = "apples" size = "3"

onChange = "appleHandler()" /> Apples

</label> </p><p>

<label> <input type = "text" name = "oranges" size = "3"

onChange = "orangeHandler()" /> Oranges

</label> </p><p>

<label> <input type = "text" name = "bananas" size = "3"

onChange = "bananaHandler()" /> Bananas

</label> </p><p>

(37)

<input type = "submit" name = "submit" /> </p>

</form> </body> </html>

// e54.js - The JavaScript file for the solution // to Exercise 5.4

var total = 0;

// The event handler functions for the text boxes function appleHandler() {

var number = document.orderForm.apples.value; total = total + number * 0.59;

}

function orangeHandler() {

var number = document.orderForm.oranges.value; total = total + number * 0.49;

}

function bananaHandler() {

var number = document.orderForm.bananas.value; total = total + number * 0.39;

}

// The event handler function to produce the total cost message // when "submit" is clicked

function finish() {

total = total * 1.05;

alert("Thank you for your order \n" +

"Your total cost is: $" + total + "\n"); }

Exercise 5.5

<!DOCTYPE html> <!-- e55.html

The XHTML part of a solution to Exercise 5.5 -->

<html lang = "en"> <head>

<title> Exercise 5.5 </title>

<script type = "text/javascript" src = "e551.js"> </script>

<meta charset = "utf-8" /> </head>

<body>

<h3> Order Form </h3>

(38)

<p>

<label> <input type = "text" id = "apples" size = "3" /> Apples

</label> </p><p>

<label> <input type = "text" id = "oranges" size = "3" /> Oranges

</label> </p><p>

<label> <input type = "text" id = "bananas" size = "3" /> Bananas

</label> </p><p>

<input type = "reset" name = "reset" /> <input type = "submit" name = "submit" /> </p>

</form>

<script type = "text/javascript" src = "e552.js"> </script>

</body> </html>

// e551.js -- The JavaScript part of the solution // to Exercise 5.5

var total = 0;

// The event handler functions for the text boxes function appleHandler() {

var myApple = document.getElementById("apples"); var number = myApple.value;

if (number < 0 || number > 99) {

alert("Error - the quantity you entered in not valid" + "\n [It is not in the range of 0 - 99] \n" + "Please enter a valid quantity");

myApple.focus(); myApple.select(); return false; }

else {

total = total + number * 0.59; return true;

} }

function orangeHandler() {

var myOrange = document.getElementById("oranges"); var number = myOrange.value;

if (number < 0 || number > 99) {

alert("Error - the quantity you entered in not valid" + "\n [It is not in the range of 0 - 99] \n" + "Please enter a valid quantity");

myOrange.focus(); myOrange.select(); return false;

(39)

} else {

total = total + number * 0.39; return true;

} }

function bananaHandler() {

var myBanana = document.getElementById("bananas"); var number = myBanana.value;

if (number < 0 || number > 99) {

alert("Error - the quantity you entered in not valid" + "\n [It is not in the range of 0 - 99] \n" + "Please enter a valid quantity");

myBanana.focus(); myBanana.select(); return false; }

else {

total = total + number * 0.49; return true;

} }

// The event handler function to produce the total cost message // when "submit" is clicked

function finish() {

total = total * 1.05;

alert("Thank you for your order \n" +

"Your total cost is: $" + total + "\n"); }

// e552.js - The JavaScript code to register the // handlers document.getElementById("apples").onchange = appleHandler; document.getElementById("oranges").onchange = orangeHandler; document.getElementById("bananas").onchange = bananaHandler;

Exercise 5.6

<!DOCTYPE html> <!-- e56.html A solution to Exercise 5.6 --> <html lang = "en"> <head>

<title> Exercise 5.6 </title>

<script type = "text/javascript" src = "e561.js" > </script>

<meta charset = "utf-8" /> </head>

(40)

<body>

<h3> Order Form </h3>

<form name = "orderForm" onSubmit = "finish()"> <p>

<label> <input type = "text" id = "apples" size = "3" /> Apples

</label> </p><p>

<label> <input type = "text" id = "oranges" size = "3" /> Oranges

</label> </p><p>

<label> <input type = "text" id = "bananas" size = "3" /> Bananas

</label> </p><p>

<input type = "reset" name = "reset" /> <input type = "submit" name = "submit" /> </p>

</form>

<script type = "text/javascript" src = "e562.js" > </script>

</body> </html>

// e561.js - Event handlers for the solution to // Exercise 5.6

var total = 0;

// The event handler functions for the text boxes function appleHandler() {

var dom = document.getElementById("apples"); var number = dom.value;

if (number < dom.min || number > dom.max) {

alert("Error - the quantity you entered in not valid" + "\n [It is not in the range of " + dom.min + " to " + dom.max + "] \n" +

"Please enter a valid quantity"); dom.focus();

dom.select(); return false; }

else {

total = total + number * 0.59; return true;

} }

function orangeHandler() {

var dom = document.getElementById("oranges"); var number = dom.value;

if (number < dom.min || number > dom.max) {

alert("Error - the quantity you entered in not valid" + "\n [It is not in the range of " + dom.min +

(41)

" to " + dom.max + "] \n" +

"Please enter a valid quantity"); dom.focus();

dom.select(); return false; }

else {

total = total + number * 0.39; return true;

} }

function bananaHandler() {

var dom = document.getElementById("bananas"); var number = dom.value;

if (number < dom.min || number > dom.max) {

alert("Error - the quantity you entered in not valid" + "\n [It is not in the range of " + dom.min + " to " + dom.max + "] \n" +

"Please enter a valid quantity"); dom.focus();

dom.select(); return false; }

else {

total = total + number * 0.49; return true;

} }

// The event handler function to produce the total cost message // when "submit" is clicked

function finish() {

total = total * 1.05;

alert("Thank you for your order \n" +

"Your total cost is: $" + total + "\n"); }

// e562.js - The body part of the JavaScript for the // solution to Exercise 5.6

// Get DOM addresses of the text boxes

var appleDom = document.getElementById("apples"); var orangeDom = document.getElementById("oranges"); var bananaDom = document.getElementById("bananas"); // Set the onchange properties for the event handlers appleDom.onchange = appleHandler;

orangeDom.onchange = orangeHandler; bananaDom.onchange = bananaHandler;

(42)

appleDom.max = 99; appleDom.min = 0; orangeDom.max = 99; orangeDom.min = 0; bananaDom.max = 99; bananaDom.min = 0;

Chapter 6

Exercise 6.1

<!DOCTYPE html> <!-- e6_1.html A solution to Exercise 6.1 --> <html lang = "en"> <head>

<title> Exercise 6.1 </title> <style type = "text/css">

/* A style for the paragraph of text */

.regtext {position: absolute; top: 100px; left: 100px;

font-family: Times; font-size: 14pt; width: 330px} /* A style for the image */

.img {background-image: url(c172.gif); position: absolute; left: 190px; top: 180px; width: 100px}

</style>

<meta charset = "utf-8" /> </head> <body> <p class = "img"> <br/><br/><br/><br/><br/> </p> <p class = "regtext">

I was born on July 4th, 1976, in Huckabee, Alaska. I have three brothers and a sister, all older than I.

My sister, Mary, is 26 years old. She lives in Kalkan, Montana. My oldest brother, Ron, is 32 years old. He lives in Huckabee. My youngest brother, Max, is 28 years old. He lives in Pinkee, Wyoming. My middle brother, Fred, is 30 years old. He lives in Kinkyhollow, Nebraska.

My parents, who are both still living, still live in Huckabee. </p>

(43)

</body> </html>

Exercise 6.2

<!DOCTYPE html> <!-- e62.html

The XHTML part of a solution to Exercise 6.2 -->

<html lang = "en"> <head>

<title> Exercise 6.2 </title> <style type = "text/css">

/* A style for the paragraph of text */

.regtext {position: absolute; top: 150px; left: 100px;

font-family: Times; font-size: 14pt; width: 330px} /* A style for the image */

.img {background-image: url(c172.gif); position: absolute; left: 100px; top: 150px; width: 100px}

</style>

<script type = "text/javascript" src = "e62.js" > </script>

<meta charset = "utf-8" /> </head>

<body>

<h2> Background Image Position Control Buttons </h2> <p>

<form name = "moveControl">

<label> <input type = "radio" name = "choser" checked = "checked"

onclick = "moveIt('picture', 150, 100)" /> Northwest

</label> <p/><p>

<label> <input type = "radio" name = "choser"

onclick = "moveIt('picture', 150, 300)" /> Northeast

</label> </p><p>

<label> <input type = "radio" name = "choser"

onclick = "moveIt('picture', 300, 300)" /> Southeast

</label> <p/><p>

<label> <input type = "radio" name = "choser"

onclick = "moveIt('picture', 300, 100)" /> Southwest

(44)

</p> </form>

<p class = "img" id = "picture"> <br/><br/><br/><br/><br/>

</p>

<p class = "regtext"> I was born on July 4th, 1976, in Huckabee, Alaska. I have three brothers and a sister, all older than I.

My sister, Mary, is 26 years old. She lives in Kalkan, Montana. My oldest brother, Ron, is 32 years old. He lives in Huckabee. My youngest brother, Max, is 28 years old. He lives in Pinkee, Wyoming. My middle brother, Fred, is 30 years old. He lives in Kinkyhollow, Nebraska.

My parents, who are both still living, still live in Huckabee. </p>

</body> </html>

// e62.js - The JavaScript file for the solution to // Exercise 6.2

/* A function to move an element */

function moveIt(movee, newTop, newLeft) { dom = document.getElementById(movee).style;

/* Change the top and left properties to perform the move */ dom.top = newTop + "px"; dom.left = newLeft + "px"; }

Exercise 6.3

<!DOCTYPE html> <!-- e63.html

The XHTML part of a solution to Exercise 6.3 -->

<html lang = "en"> <head>

<title> Exercise 6.3 </title> <style type = "text/css">

(45)

/* A style for the paragraph of text */

.regtext {position: absolute; top: 200px; left: 100px;

font-family: Times; font-size: 14pt; width: 330px} </style>

<script type = "text/javascript" src = "e63.js" > </script>

<meta charset = "utf-8" /> </head>

<body>

<h2> Background Image Visibility Control Buttons </h2>

<form name = "visibilityControl"> <p>

<label> <input type = "checkbox" name = "choser" onclick = "flipImage('northwest')" /> Northwest

</label> <p/><p>

<label> <input type = "checkbox" name = "choser" onclick = "flipImage('northeast')" /> Northeast

</label> </p><p>

<label> <input type = "checkbox" name = "choser"

onclick = "flipImage('southeast')" /> Southeast

</label> </p><p>

<label> <input type = "checkbox" name = "choser" onclick = "flipImage('southwest')" /> Southwest

</label> </p> </form>

<p id = "northwest" style = "background-image: url(c172.gif); visibility: hidden; position: absolute;

left: 100px; top: 200px; width: 100px"> <br/><br/><br/><br/><br/>

</p>

<p id = "northeast" style = "background-image: url(c172.gif); visibility: hidden; position: absolute;

left: 300px; top: 200px; width: 100px"> <br/><br/><br/><br/><br/>

</p>

<p id = "southeast" style = "background-image: url(c172.gif); visibility: hidden; position: absolute;

left: 300px; top: 350px; width: 100px"> <br/><br/><br/><br/><br/>

(46)

<p id = "southwest" style = "background-image: url(c172.gif); visibility: hidden; position: absolute;

left: 100px; top: 350px; width: 100px"> <br/><br/><br/><br/><br/>

</p>

<p class = "regtext">

I was born on July 4th, 1976, in Huckabee, Alaska. I have three brothers and a sister, all older than I.

My sister, Mary, is 26 years old. She lives in Kalkan, Montana. My oldest brother, Ron, is 32 years old. He lives in Huckabee. My youngest brother, Max, is 28 years old. He lives in Pinkee, Wyoming. My middle brother, Fred, is 30 years old. He lives in Kinkyhollow, Nebraska.

My parents, who are both still living, still live in Huckabee. </p>

</body> </html>

// e63.js - The JavaScript part of a solution to // Exercise 6.3

/* A function to change the visibility of an element */ function flipImage(img) {

dom = document.getElementById(img).style; /* Change the visibility property */

if (dom.visibility == "visible" || dom.visibility == "show") dom.visibility = "hidden"; else dom.visibility = "visible"; }

Exercise 6.5

<!DOCTYPE html> <!-- e65.html A solution to Exercise 6.5 --> <html lang = "en">

References

Related documents

Kalandoor Career DMCC Careers Dubai Customs DP World Career Dalkia Dubai Career ADGAS Career Mattex Career [email protected]. Paris Gallery

The objective of the Level I analysis is identification of environmental constraints and areas of opportunity within the study area and the selection of up to 10 initial sites

We discuss our initial experiences in using the Babel Fortran 2003 binding when calling legacy Fortran codes from the FACETS (Framework Application for Core-Edge Transport

During the abort scenario, although the Earth arrival/resupply flyby occur earlier than the nominal Earth arrival date, the time the Hermes vehicle has to transit from Mars back

Middle/intermediate and high school teachers believed challenges of implementing games effectively to be a more serious barrier than primary school teachers, while primary school

To provide context for the project, we reviewed publications, web sites, and unpublished documents related to state and national vital registration systems, electronic health record

Boudart, Jesse Alexander, &#34;Bus Replacement Modeling and the Impacts of Budget Constraints, Fleet Cost Variability, and Market Changes on Fleet Costs and Optimal Bus Replacement

FIGURE 2 | Isolates expressing serotypes present in PPV23 but not included in conjugate vaccines causing invasive pneumococcal disease in adult patients (≥18 years) in