Event-driven Programming

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

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Dreamweaver Forms Overview. Forms – A Little Review Most user/webpage communication is one way, like this: Most user/webpage communication is one way,
Computer and Communication Fundamental Basic web programming Lecture 8 Rina Zviel-Girshin.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
The Web Warrior Guide to Web Design Technologies
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Forms cs105. More Interactive web-pages So far what we have seen was to present the information. (Ex: tables. Lists,….). But it is not enough. We want.
JavaScript Forms Form Validation Cookies CGI Programs.
Computing Concepts Advanced HTML: Tables and Forms.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Lesson 8 Creating Forms with JavaScript
CST JavaScript Validating Form Data with JavaScript.
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.,
Visual Basic Chapter 1 Mr. Wangler.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
1 Forms A form is the usual way that information is gotten from a browser to a server –HTML has tags to create a collection of objects that implement this.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
JavaScript II ECT 270 Robin Burke. Outline JavaScript review Processing Syntax Events and event handling Form validation.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
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.
JavaScript: Functions © by Pearson Education, Inc. All Rights Reserved.
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.
Lecture # 6 Forms, Widgets and Event Handling. Today Questions: From notes/reading/life? Share Personal Web Page (if not too personal) 1.Introduce: How.
© 2010 Delmar, Cengage Learning Chapter 8 Collecting Data with Forms.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
USING XML AS A DATA SOURCE. Data binding is a process by which information in a data source is stored as an object in computer memory. In this presentation,
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
44238: Dynamic Web-site Development Client Side Programming Ian Perry Room:C48 Extension:7287
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
Client-Side programming with JavaScript 2. Event-driven programs and HTML form elements event-driven programs  onload, onunload  HTML forms & attributes.
The Web Wizard’s Guide To JavaScript Chapter 3 Working with Forms.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
Javascript JavaScript is what is called a client-side scripting language:  a programming language that runs inside an Internet browser (a browser is also.
Understanding JavaScript and Coding Essentials Lesson 8.
JavaScript II ECT 270 Robin Burke. Outline Functions Events and event handling Form validation.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
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.
Learning Aim C.  In this section we will look at how text, tables, forms and frames can be used in web pages.
CSC 121 Computers and Scientific Thinking Fall Event-Driven Programming.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
HTML Tutorial. What is HTML HTML is a markup language for describing web documents (web pages) HTML documents are described by HTML tags Each HTML tag.
HTML III (Forms) Robin Burke ECT 270. Outline Where we are in this class Web applications HTML Forms Break Forms lab.
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
Ashima Wadhwa Java Script And Forms. Introduction Forms: –One of the most common Web page elements used with JavaScript –Typical forms you may encounter.
Chapter 5 Validating Form Data with JavaScript
Event-Driven Programming
In this session, you will learn to:
Forms Web Design Ms. Olifer.
Section 17.1 Section 17.2 Add an audio file using HTML
HTML IV (Forms) Robin Burke ECT 270.
© 2015, Mike Murach & Associates, Inc.
Web Design and Development
Events: Changed and Input
Presentation transcript:

Event-driven Programming Robin Burke IT 130 Fall 2004

Outline The event-driven model Web applications Form HTML Handlers forms buttons text boxes accessing form content Handlers onClick onChange

Imperative programming defines a series of operations User invokes program waits for result "Batch" processing

Event-driven programming Modern applications are event-driven Different kind of programming from sequential (batch) execution programmer does not control when code is executed user controls that Programmer provides capabilities the user invokes them may be multiple ways to do the same thing Basic idea = "event handlers" small bits of code that the application calls when certain events occur

Event-driven programming cont'd Imperative program load payroll data do payroll computation output checks Event-oriented program establish payroll application interface associate loading routine with "load" menu item associate payroll computation with "compute" menu option associate check printing operation with "print" menu options User is in charge of the sequence

Basic idea Events are generated To use an event, the programmer user actions (clicking, moving mouse) browser actions (loading, closing) To use an event, the programmer writes JavaScript code associates it with the appropriate document element associates it with the appropriate event

Pieces we need New HTML elements New HTML attributes forms interface widgets buttons, text boxes, etc. New HTML attributes event generation New JavaScript capabilities associate code with events

Web application Application Web application "A complete, self-contained program that performs a specific function directly for the user" Web application an application delivered over the WWW

Web applications Core of web development Not in our scope But 90% of the web's "pages" are generated from user input only 10% are static pages Not in our scope IT 230 teaches how to build those kinds of applications we will not use forms as input to applications But web applications need input input comes from HTML forms we can use form element to explore event handling

Example applications Course online Any search engine

What all these share... The need to get user input from a web page Format of input name-value pair Interaction idea web form How to get from user? depends on the data

Form elements Form element Input element identify a part of the page where the user can input data Input element specific data items name and value attributes user can change the value attribute

Input elements name and value attributes user can change the value attribute how depends on the type text field selection list radio button, etc

Example

Input elements Treated like other page elements can be organized into paragraph, tables, etc. Form layout is almost always table-based All use the same base element INPUT what kind of input controlled by the type attribute

Input elements

Textarea for multi-line input <textarea name="message" rows=4 cols=40 wrap="virtual"></textarea>

Select / Option for menus and lists <select size="3"> <option>BS CGA-DES</option> <option>BS CGA-DEV</option> <option>BA DC</option> <option>BS DC</option> ... </select>

Input elements we will use type="button" rendered as a "raised" rectangle user can click type="text" rendered as an "indented" box can display text user can enter text

Examples Button Text box more typical (with label) <input type="button" value="Click Here for Lucky Number" /> Text box <input type="text" name="fahrBox" size="10" value "" /> more typical (with label) Enter a temperature in degrees Fahrenheit: <input type="text" name="fahrBox" size="10" value "" />

Events Any HTML element can generate events Commonly-used many different types Commonly-used button  click event when the user clicks on the button text  change event when the user changes the value

Linking element and event event handler attribute when the event occurs on that element the JavaScript statement will execute Example onClick="Convert();" In Element <input type="button" value="Convert to Celsius" onClick="Convert();" />

Example lucky.html

Programming rollem.html

Interacting with form values Form data name / value pairs processed by the server can also be manipulated by JavaScript Change the value of a form element changes what the user sees Linked to events we can create simple browser-based applications

Syntax Getting a value Setting a value Refer to subparts using dot (.) syntax Format document.FORM_NAME.ELEMENT_NAME.value Getting a value tempF = document.TempForm.fahrBox.value; Setting a value document.TempForm.celsiusBox.value = tempC;

Examples lucky1.html convert1.html

Programming convert2.html

Dynamic HTML JavaScript can alter many HTML properties Example we see more of this later in the class Example alter the src attribute of an img element pics.html

onChange event onClick event For text elements Example user presses a button For text elements onChange event when the user alters the contents and then clicks outside the element Example copybox.html

Homework #5 Metric conversions You need to add two conversions work inches <--> cm feet <--> meters You need to add miles <--> km

Structure convert.js hwk5.html Tasks a library with the conversion functions hwk5.html the page that interacts with the user Tasks add lines for miles / km and text elements add functions that handle onChange events add conversion functions to convert.js

Advice Start early Use cut, paste and edit! Don't forget documentation 45-50 lines of code to write Use cut, paste and edit! Don't forget documentation Test each step

Wednesday Lab (Rm 722) Forms and Events Good practice for the homework