WEB PROGRAMMING AND INTERNET TECHNOLOGIES - Jones & Bartlett Learning

1y ago
17 Views
2 Downloads
1.37 MB
24 Pages
Last View : 1d ago
Last Download : 3m ago
Upload by : Dahlia Ryals
Transcription

WEB PROGRAMMING AND INTERNET TECHNOLOGIES An E-Commerce Approach SECOND EDITION Porter Scobey, PhD Saint Mary’s University Pawan Lingras, PhD Saint Mary’s University 9781284078855 FMxx Pass02.indd 1 27/07/16 4:31 AM

World Headquarters Jones & Bartlett Learning 5 Wall Street Burlington, MA 01803 978-443-5000 info@jblearning.com www.jblearning.com Jones & Bartlett Learning books and products are available through most bookstores and online booksellers. To contact Jones & Bartlett Learning directly, call 800-832-0034, fax 978-443-8000, or visit our website, www.jblearning.com. Substantial discounts on bulk quantities of Jones & Bartlett Learning publications are available to corporations, p rofessional associations, and other qualified organizations. For details and specific discount information, contact the special sales department at Jones & Bartlett Learning via the above contact information or send an email to specialsales@jblearning.com. Copyright 2018 by Jones & Bartlett Learning, LLC, an Ascend Learning Company All rights reserved. No part of the material protected by this copyright may be reproduced or utilized in any form, electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system, without written permission from the copyright owner. The content, statements, views, and opinions herein are the sole expression of the respective authors and not that of Jones & Bartlett Learning, LLC. Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not constitute or imply its endorsement or recommendation by Jones & Bartlett Learning, LLC and such reference shall not be used for advertising or product endorsement purposes. All trademarks displayed are the trademarks of the parties noted herein. Web Programming and Internet Technologies: An E-Commerce Approach, Second Edition is an independent publication and has not been authorized, sponsored, or otherwise approved by the owners of the trademarks or service marks referenced in this product. There may be images in this book that feature models; these models do not necessarily endorse, represent, or participate in the activities represented in the images. Any screenshots in this product are for educational and instructive purposes only. Any individuals and scenarios featured in the case studies throughout this product may be real or fictitious, but are used for instructional purposes only. 07885-5 Production Credits VP, Executive Publisher: David D. Cella Acquisitions Editor: Laura Pagluica Editorial Assistant: Taylor Ferracane Director of Vendor Management: Amy Rose Director of Marketing: Andrea DeFronzo Marketing Manager: Amy Langlais VP, Manufacturing and Inventory Control: Therese Connell Composition and Project Management: S4Carlisle Publishing Services Cover Design: Kristin E. Parker Rights & Media Specialist: Merideth Tumasz Media Development Editor: Shannon Sheehan Cover Image: Godruma/Shutterstock Printing and Binding: RR Donnelley Cover Printing: RR Donnelley Library of Congress Cataloging-in-Publication Data Names: Scobey, Porter, author. Lingras, Pawan, author. Title: Web programming and Internet technologies : an E-commerce approach / Porter Scobey, PhD, Pawan Lingras, PhD, both of Saint Mary’s University. Description: Second edition. Burlington, Massachusetts : Jones & Bartlett Learning, [2017] Includes bibliographical references and index. Identifiers: LCCN 2016028087 ISBN 9781284070682 Subjects: LCSH: Web site development. Business enterprises—Data processing. Classification: LCC TK5105.888 .S388 2017 DDC 006.7—dc23 LC record available at https://lccn.loc.gov/2016028087 6048 Printed in the United States of America 20 19 18 17 16 10 9 8 7 6 5 4 3 2 1 9781284078855 FMxx Pass02.indd 2 27/07/16 4:31 AM

DEDICATION To the memory of my mother and father, who likely would not have read it, but would have liked a copy for their coffee table; and to Patricia, who might even read it, but would insist that its sojourn on our coffee table be short-lived. —PORTER SCOBEY To my family, who may have a similar vague and equally short-lived sense of joy and pride. —PAWAN LINGRAS 9781284078855 FMxx Pass02.indd 3 27/07/16 4:31 AM

9781284078855 FMxx Pass02.indd 4 27/07/16 4:31 AM

TABLE OF CONTENTS Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv Typographic and Other Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii 1 Setting the Scene 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 2 Establishing a Web Presence 2.1 2.2 2.3 2.4 2.5 1 What Is the Internet?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 What Is the World Wide Web?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 What Is Meant by a Client-Server Architecture? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 How Do Web Browsers and Web Servers Fit the Client-Server Model?. . . . . . . . . . . . . 4 How Do Web Browsers and Web Servers Communicate?. . . . . . . . . . . . . . . . . . . . . . . . 5 1.5.1 Web Protocols and Layered Communication Architectures. . . . . . . . . . . . . . . . . . . . . . . . 5 1.5.2 Web Addresses and Address Resolution via DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.5.3 URLs, URNs, and URIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 A Real-World E-Commerce Website . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 The Technologies We Will Discuss. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Some Alternative Technologies and Additional Tools . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Quick Questions to Test Your Basic Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Short Exercises to Improve Your Basic Understanding. . . . . . . . . . . . . . . . . . . . . . . . . . 16 Exercises on the Parallel Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 What Else You May Want or Need to Know. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 25 What Is an Internet Service Provider (ISP)?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 What Tools Will You Need to Begin Your Web Development? . . . . . . . . . . . . . . . . . . . 28 How Do You Create a Simple, Static Web Page? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 How Do You Test a Web Page “Offline” before “Going Online”? . . . . . . . . . . . . . . . . 30 How Do You “Go Live” on the Web Once You’re Ready? . . . . . . . . . . . . . . . . . . . . . . . 31 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Quick Questions to Test Your Basic Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Short Exercises to Improve Your Basic Understanding. . . . . . . . . . . . . . . . . . . . . . . . . . 36 Exercises on the Parallel Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 What Else You May Want or Need to Know. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 v 9781284078855 FMxx Pass02.indd 5 27/07/16 4:31 AM

vi Table of Contents 3 HTML for Content Structure 43 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 The Long Road to HTML5, the New Norm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 A Very Important Distinction: Structure vs. Presentation . . . . . . . . . . . . . . . . . . . . . . . . 46 HTML Tags and Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 The Basic Structure of Every Web Page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Some Basic Markup: Headings, Paragraphs, Line Breaks, and Lists . . . . . . . . . . . . . . . 49 What Does It Mean for a Web Page to Be Valid? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 How Can We Determine if a Web Page Is Valid? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Validating with the Firefox Web Developer Add-on. . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Tables, Images, and Tag Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 HTML Entities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Adding More Web Pages to Our Site and Connecting Them with Hyperlinks . . . . . . 62 3.11.1 A Menu of Hyperlinks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 3.11.2 Our Site Now Has Many Pages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 3.11.3 Beware the “Legacy Fix”!. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 3.12 Using Server-Side Includes (SSI) to Make Common Markup Available to Multiple Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 3.12.1 The “Maintenance Nightmare” Problem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 3.12.2 Identifying and Extracting Common Markup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 3.12.3 Using SSI to Include Common Markup Where Needed. . . . . . . . . . . . . . . . . . . . . . . . . . 72 3.12.4 One Thing Leads to Another: A Second Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 3.12.5 The base Tag Solves Our Second Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 3.12.6 Our Revised Site Looks and Behaves Exactly Like the Previous Version. . . . . . . . . . . . 76 3.13 The New HTML5 Semantic Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 3.13.1 Block-level Elements and Inline-level Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 3.13.2 Semantic Elements and Non-Semantic Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 3.13.3 Two More Legacy Elements: div and span. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 3.13.4 New Semantic Elements in HTML5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Quick Questions to Test Your Basic Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Short Exercises to Improve Your Basic Understanding. . . . . . . . . . . . . . . . . . . . . . . . . . 80 Exercises on the Parallel Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 What Else You May Want or Need to Know. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 4 CSS for Content Presentation 4.1 4.2 4.3 4.4 4.5 4.6 9781284078855 FMxx Pass02.indd 6 91 The Rationale for CSS, and a Brief History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Simple CSS Style Rules and Their Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 The Placement of CSS Style Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 A Simple Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Some Basic CSS Markup: More on Selectors, Declarations, Properties, and Property Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Some Common Types of CSS Property Values and Their Formats . . . . . . . . . . . . . . . . 99 4.6.1 Specifying Measurement Property Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 4.6.2 Specifying Color Property Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 4.6.3 The Important Takeaway from This Section. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 27/07/16 4:31 AM

Table of Contents 4.7 4.8 4.9 4.10 4.11 4.12 4.13 CSS Style Sheet Structure, Comments, and Formatting. . . . . . . . . . . . . . . . . . . . . . . . 102 The HTML class and id Attributes and the Non-Semantic HTML div and span Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 4.8.1 The HTML class and id Attributes (CSS class and id Selectors). . . . . . . . . . . . 105 4.8.2 The HTML div and span Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 4.8.3 Using Our Class Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Inheritance and the Cascade. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 4.9.1 Inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 4.9.2 The “Cascade” and Resolution of Style Conflicts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 4.9.3 Applying the Theory to Our Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Validating Our CSS Style Sheets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 The CSS Box Model and Simple CSS Page Layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 4.11.1 The CSS Box Model: A Conceptual View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 4.11.2 The CSS Box Model: A Detailed Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 4.11.3 Simple CSS Page Layout with float and clear via the “Legacy” Approach with div Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 4.11.4 Simple CSS Page Layout with float and clear via the “Modern” Approach with HTML5 Semantic Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 CSS Reset: A “Best Practice” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Styling Our Nature’s Source Website with CSS (Four Versions, Illustrating CSS3, Simple “Responsive Design”, and the New HTML5 video Element). . . . . . . . 128 4.13.1 Version 1: A Simple Home Page Only. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 4.13.2 Version 2: A Multipage Site with Menu and Footer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 4.13.3 Version 3: A Revision of Version 2 Incorporating Some CSS3 and Illustrating Simple “Responsive Design” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 4.13.4 Version 4: A Copy of Version 3 with the Home Page Image Replaced by a Home Page Video. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 Quick Questions to Test Your Basic Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Short Exercises to Improve Your Basic Understanding. . . . . . . . . . . . . . . . . . . . . . . . . 153 Exercises on the Parallel Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 What Else You May Want or Need to Know. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 5 HTML Forms for Data Collection 5.1 5.2 5.3 5.4 5.5 5.6 vii 163 Web Forms Collect User Input Data in a Browser for Transfer to a Server for Processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 The form Element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 5.2.1 A Brief Aside, a Reminder, and Some Good Advice . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 5.2.2 How Will We Deal with CSS from Now On? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 The input Element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 5.3.1 Textboxes (input Elements of Type text). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 5.3.2 Radio Buttons (input Elements of Type radio). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 5.3.3 Checkboxes (input Elements of Type checkbox). . . . . . . . . . . . . . . . . . . . . . . . . . . 173 The select and option Elements for Dropdown List-boxes. . . . . . . . . . . . . . . . . . 173 What Is Missing from the BMI Calculator Web Page? . . . . . . . . . . . . . . . . . . . . . . . . . 174 The textarea Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 9781284078855 FMxx Pass02.indd 7 27/07/16 4:31 AM

viii Table of Contents 5.7 5.8 5.9 5.10 5.11 The submit and reset Button Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Organizing Form Controls with the fieldset and legend Elements . . . . . . . . . . . 179 Using the label Element for Behind-the-Scenes Logical Groupings . . . . . . . . . . . . 184 Getting Ready to Submit Your Form Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 HTML5 Form Controls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 Quick Questions to Test Your Basic Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 Short Exercises to Improve Your Basic Understanding. . . . . . . . . . . . . . . . . . . . . . . . . 189 Exercises on the Parallel Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 What Else You May Want or Need to Know. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 6 JavaScript for Client-Side Computation and Form Data Validation 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 9781284078855 FMxx Pass02.indd 8 193 Another Important Distinction: Structure vs. Presentation vs. Behavior. . . . . . . . . . . 195 What Is JavaScript? (It’s not Java!) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 6.2.1 JavaScript Is Interpreted, Not Compiled. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 6.2.2 Restrictions on What JavaScript Can Do. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 6.2.3 How Will We Use JavaScript? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 The Placement of JavaScript Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 A Simple Example in Four Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 6.4.1 Version 1: No JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 6.4.2 Version 2: Embedded JavaScript and document.write() . . . . . . . . . . . . . . . . . . . 199 6.4.3 Version 3: Linking to an External JavaScript File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 6.4.4 Version 4: Another External Script, the alert() Method, and Escape Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 What Is the Document Object Model (DOM )?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 JavaScript and the DOM Interact to Process Our BMI Form. . . . . . . . . . . . . . . . . . . . 209 6.6.1 A First Programmer-Defined JavaScript Function: Function Syntax . . . . . . . . . . . . . . 210 6.6.2 JavaScript Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 6.6.3 Accessing a DOM Element via Its id Attribute. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 6.6.4 Making Decisions with the JavaScript if-else Statement. . . . . . . . . . . . . . . . . . . . . 214 6.6.5 Accessing a DOM Element via Its name Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 The Importance of Website Security and How JavaScript Can Help. . . . . . . . . . . . . 217 JavaScript and the DOM Interact to Validate Our BMI Form Data. . . . . . . . . . . . . . . 217 6.8.1 Simple JavaScript Arrays, and the options Array of a select Element . . . . . . . . 219 6.8.2 Getting the Height and Weight Units Chosen by the User. . . . . . . . . . . . . . . . . . . . . . . 220 6.8.3 Getting the User’s Height and Weight Values, and Email Address. . . . . . . . . . . . . . . . .221 6.8.4 Calling Functions to Validate Height, Weight, and Email Values . . . . . . . . . . . . . . . . . 221 6.8.5 Logical Operators and Compound Boolean Expressions. . . . . . . . . . . . . . . . . . . . . . . . 222 6.8.6 Relational Operators and Functions for Validating Height and Weight Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 6.8.7 Simple Regular Expressions and a Function for Validating an Email Address . . . . . . 224 JavaScript and the DOM Interact to Compute a BMI Value. . . . . . . . . . . . . . . . . . . . 227 6.9.1 Numerical Calculations: Three Functions Compute the BMI Value. . . . . . . . . . . . . . . 228 6.9.2 Setting the Precision of the BMI Value and Displaying a Detailed Report. . . . . . . . . . 229 27/07/16 4:31 AM

Table of Contents ix 6.10 Regular Expressions in JavaScript and in HTML5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 6.11 JavaScript and the DOM Interact to Validate Our Feedback Form Data. . . . . . . . . . 236 6.11.1 Validating First and Last Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 6.11.2 Validating Telephone Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 6.11.3 Validating Email Addresses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 6.12 The Modernizr Tool and HTML5 Form Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 Quick Questions to Test Your Basic Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 Short Exercises to Improve Your Basic Understanding. . . . . . . . . . . . . . . . . . . . . . . . . 251 Exercises on the Parallel Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 What Else You May Want or Need to Know. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 7 JavaScript for Client-Side Content Behavior 7.1 7.2 7.3 7.4 Enhancing Our Website with a Home Page “Slide Show” of Rotating Images and Dropdown Menu Options on Every Page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 Implementing Our “Slide Show” of Rotating Images. . . . . . . . . . . . . . . . . . . . . . . . . . 264 7.2.1 The onload Attribute of the body Element: Starting the Slide Show after the Home Page Loads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 7.2.2 The Revised img Element for the Slide Show. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 7.2.3 The rotate.js Script. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 Implementing Our Dropdown Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 7.3.1 An Overview of How Our Dropdown Menus Work. . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 7.3.2 The onmouseover and onmouseout Attributes: Showing and Hiding Dropdown Menu Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277 7.3.3 The CSS for Our Dropdown Menus. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 7.3.4 The JavaScript for Our Dropdown Menus: The show() and hide() Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 Notes on the nature2 Version of Our Nature’s Source Website. . . . . . . . . . . . . . . . 280 7.4.1 What’s New in Our BMI Form? . . . . . . . . . . . .

WEB PROGRAMMING 9781284078855_FMxx_Pass02.indd 1 27/07/16 4:31 AM. World Headquarters Jones & Bartlett Learning 5 Wall Street Burlington, MA 01803 978-443-5000 info@jblearning.com www.jblearning.com Jones & Bartlett Learning books and products are available through most bookstores and online booksellers. To contact Jones & Bartlett

Related Documents:

Programming the WEB 10CS73 connected to the Internet. Information that travels over the Internet does so via a variety of languages known as protocols. The World Wide Web, or simply Web, is a way of accessing information over the medium of the Internet. The Web uses the HTTP protocol The Web also utilizes

MIT 11.188/11.520 Web Service Notes 1 Internet GIS and Geospatial Web Services Introduction Section 1 -- What is Internet GIS? Section 2 -- Internet GIS: state of practice Section 3 -- Future development of Internet GIS Section 4 -- Function comparisons of current Internet GIS programs Section 5 -- Internet GIS applications Section 6 – I

Objectives: To impart the skills needed for web programming, web administration, and web site development. After studying this course student can develop; static web pages; dynamic web pages; data Processing on web pages. S. No. Description 1. Internet Fundamentals: Introduction to Internet, Web browser, web page, website, homepage, hyperlinks,

Programming the World Wide Web 6 ed., Robert W. Sebesta. Addison Wesley, 978-0-13-213081-3 Course Description: CS 3950 Web Technologies 4 cr. An introduction to the programming tools and skills used to build and maintain web applications. Topics include: the World Wide Web, the HTTP protocol, Web standards, HTML and XHTML, CSS, client-side

Programming the World Wide Web, 2010 / Robert W. Sebesta. -- 6th ed. p. cm. Previous eds. under title: Programming the World Wide Web. ISBN 978-0-13-213081-3 1. Internet programming. 2. World Wide Web. I. Sebesta, Robert W. Programming the World Wide Web. II. Title. QA76.625.S42 2010b 006.7'6--dc22 2009053855

Fundamental of Internet Programming Compiled by Ayantu G. Page 4 H. Web server A web server is a computer that stores a web site, and is responsible for checking requests for viewing that web site. Client computers send requests for particular URLs to the web server, which then finds the approp

LESSON TWO Back-End Programming Learn about back-end web programmers who write server-side code to build web apps that serve millions of people worldwide LESSON THREE Mobile Programming Learn about mobile programming and the differences between iOS and Android programming LESSON FOUR Data Analysis Programming

4. Apply CSS types for different web pages 5. Design an interactive web site using web technologies HTML, CSS and Javascript Course Outcomes On completion of the course, student will be able to: 1. Describe different web technologies used for web application development 2. Distinguish between server-side and client-side web technologies 3.