Web-based Application Development Lecture 11 February 14, 2006 Anita Raja.

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

Essentials for Design JavaScript Level One Michael Brooks
Java Script Session1 INTRODUCTION.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
Lesson 12- Unit L Programming Web Pages with JavaScript.
The Web Warrior Guide to Web Design Technologies
Web-based Application Development Lecture 9 February 7, 2006 Anita Raja.
Programming System development life cycle Life cycle of a program
JavaScript- Introduction. What it is and what it does? What it is? It is NOT Java It is NOT Server-side programming Users can see code It is a client-side.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 7 Event-Driven.
Tutorial 10 Programming with JavaScript
HTML Recall that HTML is static in that it describes how a page is to be displayed, but it doesn’t provide for interaction or animation. A page created.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
8 November Forms and JavaScript. Types of Inputs Radio Buttons (select one of a list) Checkbox (select as many as wanted) Text inputs (user types text)
Information Technology Center Hany Abdelwahab Computer Specialist.
Web-based Application Development Lecture 13 February 21, 2006 Anita Raja.
Web-based Application Development Lecture 18 March 21, 2006 Anita Raja.
Computer Science 103 Chapter 4 Advanced JavaScript.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Programming Concepts and Languages Chapter 12 – Computers: Understanding Technology, 3 rd edition 1November
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
1 Events Lect 8. 2 Event-driven Pages one popular feature of the Web is its interactive nature e.g., you click on buttons to make windows appear e.g.,
© Paradigm Publishing Inc Chapter 12 Programming Concepts and Languages.
Javascript and the Web Whys and Hows of Javascript.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
CC111 Lec#5: Program Development 1 Program Development and Programming Languages Lecture 4 Reference :Understanding Computers Chapter 13.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
Designing and Debugging Batch and Interactive COBOL Programs Chapter 5.
Client Side Programming with JavaScript Why use client side programming? Web sides built on CGI programs can rapidly become overly complicated to maintain,
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
CSCE 102 – Chapter 7 (Intro. to Program. & JavaScript ) CSCE General Applications Programming Benito Mendoza Benito Mendoza 1 By Benito.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Programming the Web using XHTML and JavaScript
Programming Mehdi Bukhari.
Section 17.1 Section 17.2 Add an audio file using HTML
Programming Concepts and Languages
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Tutorial 10: Programming with javascript
Introduction to Programming and JavaScript
Web Programming and Design
Presentation transcript:

Web-based Application Development Lecture 11 February 14, 2006 Anita Raja

Programming the Web using XHTML and JavaScript Chapter 7 Introduction to Programming and JavaScript

Programming Techniques Brute Force Traveling Salesman Problem

Programming Techniques New York Boston Washington Philadelphia Chicago Atlanta St. Louis Denver Houston Seattle Los Angeles

Programming Techniques Brute Force Traveling Salesman Problem Algorithm “A detailed sequence of actions to perform to accomplish some task” 1 Al-Khawarizmi Died about 840 A.D. HUGE influence on algebra (name comes from his book) 1. Free On-Line Dictionary of ComputingFree On-Line Dictionary of Computing

Control Structures Sequence 1.Do this. 2.Do something else. 3.Do another thing.

Control Structures Sequence Conditional (if-then, branching) 1.Do this. 2.Do something else. 3.If some condition is true then 3a. Do this bit Otherwise 3b. Do these things. 4.Do another thing. The steps you do if the condition is true The steps you do if the condition is false

Control Structures Sequence Conditional Looping (iteration) 1.Do this. 2.Do something else. 3.Do the following steps x number of times 3a. Do this sub-step 3b. Do another sub-step. 4.Do another thing.

Control Structures Sequence Conditional Looping Transfer (go to) 1.Do this. 2.Go to step 4. 3.Do something else. 4.Do another thing. 5.Go to step 1. Never gets executed

Programming Techniques Unstructured “Go To Statement Considered Harmful” Edsger W. Dijkstra, 1968 Structured Top-down construction Object-Oriented “Objects” composed of data and instructions Self-contained

Control Structures Flowcharts (graphical symbols)

Control Structures Pseudocode (half code, half natural) While the stoplight is red, stop. If the stoplight is green then continue on. Advantages: Avoids programming language technicalities Easy to understand and change

JavaScript Programming languages C, C++, Java, COBOL, FORTRAN Stand-alone software Scripting languages JavaScript, VBScript “Mini” program that runs inside another program Cannot be used outside that application

JavaScript Compilers Translates entire source file at once Produces a single executable file Interpreters Translates source statements one at a time Immediately executes each statement

JavaScript Browsers have two functions: HTML Translate the tags Display the content appropriately JavaScript Interpret a line Execute the line Both are executed in order

JavaScript JavaScript code composed of: Instructions/Commands/Statements Case sensitive! Inserted directly into HTML element (scripting commands)

JavaScript More than one scripting language Must specify JavaScript in XHTML code …

JavaScript Don’t confuse HTML with JavaScript … HTML JavaScript

Can have multiple elements in one HTML document Ch07-Ex-01.htm

JavaScript Can access JavaScript code stored in an external file … Only JavaScript code in the.js file, not the tags

JavaScript External files Good for repeated code Hides code from casual users

Entomology of Programming “a branch of zoology that deals with insects ”, i.e., debugging

Entomology of Programming

Naval Surface Warfare Center Computer Museum at Dahlgren, Virginia

Entomology of Programming

Dare and Do

Entomology of Programming Error types: Syntax Constructed improperly Logic Constructed properly but does not achieve the desired result

Entomology of Programming alert(“My first JavaScript.) Alert(“Too exciting for words.”) alert[“This is big time stuff.”] Spelling Closing quote Capital letter Square brackets

Entomology of Programming Ch07-Ex-02.htm

Entomology of Programming Browser errors Message box: Line number – not always accurate Error – not always informative Skips: Invalid line and All subsequent lines in same element

Entomology of Programming Fixing errors Correct line by line Use trial and error Rewrite code entirely Use comments to eliminate items

Comments Help other readers Help yourself at a later time Eliminate sections of code during debugging

Comments Single-line alert(“Hi!”) // A friendly greeting // End of this script element

Comments Multiple-line /* This is a multiple line comment. */ /* So is this */

Comments Don’t confuse with HTML comment: <!-- This is an HTML comment -->

Interactivity HTML has form elements like text boxes, check boxes, radio buttons, etc. JavaScript permits processing of these elements

Interactivity Events An action associated with some object Types: Click Select Mouseover Ch07-Ex-03.htm

Interactivity Browser automatically tracks events Programmers job is to write code that responds to events Event Handler

Interactivity Sequence of events: User clicks the button Browser automatically detects the click Browser generates a click event Event handler associated with the button is triggered JavaScript commands associated with that event are processed

Interactivity onclick attribute describes the action(s) to take when a click event is detected <input type=“button” … ¬ onclick=“alert(‘You clicked me’)” /> alert is JavaScript exception to rule Ch07-Ex-04.htm

Interactivity Multiple JavaScript commands are valid <input type=“button” … ¬ onclick=“alert(‘You clicked me’)”; onclick=“alert(‘Well done’)” />

Interactivity Mouse events onmouseover – when cursor is moved over an object onmouseout – when cursor over an object moves away from the object Ch07-Ex-05.htm

Assignment Debugging Exercise, p. 209 Correct errors Post corrected document to your Web space as “Lagerstrom-Ch-7.html” Grade based on: Appearance Technical correctness of code