1 COMM 1213 H1 COMP 4923 X1 JavaScript 2 (Readings: Ch. 12, 13, 14 Knuckles)

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

Chapter 7 JavaScript: Introduction to Scripting. Outline Simple Programs Objects and Variables Obtaining User Input with prompt Dialogs – –Dynamic Welcome.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
1 COMM 1213 H1 COMP 4923 X1 JavaScript 1 (Readings: Ch. 10, 11 Knuckles)
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.
Chapter 7 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 7 Sebesta: Programming the World Wide Web.
JavaScript Forms Form Validation Cookies CGI Programs.
HTML Comprehensive Concepts and Techniques Second Edition Project 8 Integrating JavaScript with HTML.
Computer Science 103 Chapter 4 Advanced JavaScript.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
More about JavaScript INE2720 Web Application Software Development Essential Materials.
CST JavaScript Validating Form Data with JavaScript.
JS: DOM Form Form Object Form Object –The Form object represents an HTML form. –For each instance of a tag in an HTML document, a Form object is created.
Using Dreamweaver. Slide 1 Dreamweaver has 2 screens that do different things The Document window where you create your WebPages The Site window where.
JavaScript - Document Object Model. Bhawna Mallick 2 Unit Plan What is DOM and its use? Hierarchy of DOM objects. Reflection of these objects in an HTML.
Server vs Client-side validation. JavaScript JavaScript is an object-based language. JavaScript is based on manipulating objects by modifying an object’s.
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.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT
Execution Environment for JavaScript " Java Script Window object represents the window in which the browser displays documents. " The Window object provides.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part Two.
JavaScript Part 1.
Chapter 3 : Processing on the Front End JavaScript Technically its name is ECMA-262, which refers to the international standard which defines it. The standard.
JavaScript Lecture 6 Rachel A Ober
Arrays – What is it? – Creation – Changing the contents Functions – What is it? – Syntax – How they work – Anonymous functions A quick lesson in Objects.
Integrating JavaScript and HTML5 HTML5 & CSS 7 th Edition.
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.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Adobe GoLive Edit and FTP your web pages to a web server.
Using Client-Side Scripts to Enhance Web Applications 1.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
HTML FORMS GET/POST METHODS. HTML FORMS HTML Forms HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes,
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
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.
CS 174: Web Programming September 28 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
JavaScript, Fourth Edition
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Lesson 16. Practical Application 1 We can take advantage of JavaScript and the DOM, to set up a form so that the first text box of a form automatically.
HTML DOM Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
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.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
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.
JavaScript and Ajax Week 10 Web site:
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
Chapter 5 Validating Form Data with JavaScript
JavaScript and HTML Simple Event Handling 11-May-18.
In this session, you will learn to:
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
JavaScript 3 (Readings: Ch. 15 Knuckles)
JavaScript is a programming language designed for Web pages.
JavaScript.
Section 17.1 Section 17.2 Add an audio file using HTML
Web Development & Design Foundations with HTML5 7th Edition
JAVASCRIPTS AND HTML DOCUMENTS
14 A Brief Look at JavaScript and jQuery.
JavaScript and HTML Simple Event Handling 19-Sep-18.
T. Jumana Abu Shmais – AOU - Riyadh
JavaScript Basics What is JavaScript?
JavaScript and HTML Simple Event Handling 26-Aug-19.
JavaScript and HTML Simple Event Handling 4-Oct-19.
Presentation transcript:

1 COMM 1213 H1 COMP 4923 X1 JavaScript 2 (Readings: Ch. 12, 13, 14 Knuckles)

2 Outline Objects = Properties + Methods Objects = Properties + Methods Document Object Model Document Object Model Window and Document Properties and Methods Window and Document Properties and Methods HTML Forms HTML Forms

3 Objects (Ch. 12) An object is composed of: An object is composed of: –Properties or Variables (holds values) –Methods (perform functions) A car is a class of objects that have: A car is a class of objects that have: –Properties: colour, size, numdoors –Methods: move, stop, soundhorn The lowest level properties of type number, string, Boolean are called primitives The lowest level properties of type number, string, Boolean are called primitives var num; declares the primitive variable “num” var num; declares the primitive variable “num”

4 Objects A pizza is an object that can have the properties: type and price A pizza is an object that can have the properties: type and price –Declared by: var pizza=new Object(); pizza.price=15.00; A bill is an object that can have the properties: subtotal, tax and total A bill is an object that can have the properties: subtotal, tax and total var bill=new Object(); bill.subtotal=num*pizza.price; New version of the pizza program: New version of the pizza program:

5 Window Object Hierarchy Objects can have objects as properties eg. Cars can have engines Objects can have objects as properties eg. Cars can have engines –that have pistons that have rings that have rings DOM = DOM = Document Object Model Defines the hierarchy of Defines the hierarchy of objects within the browser window

6 Document Object Model window object prefix can be dropped window object prefix can be dropped window.closed or closed is a Boolean variable = false window.closed or closed is a Boolean variable = false history contains info on previous documents visited history contains info on previous documents visited –history.length is number of previous documents document.bgcolor contains the current background colour document.bgcolor contains the current background colour document.form1.var1.value contains the value of a variable var1 of the form object form1 of the current document object document.form1.var1.value contains the value of a variable var1 of the form object form1 of the current document object

7 Using Window and Document Object Properties Figure 12.6 Knuckles

8 Using Window and Document Object Methods <HTML><HEAD> <!-- var transfer; transfer=window.confirm("This web page has moved to a new location. Choose ok if you wish to be transported there."); if(transfer){ window.location="newpage.html"; window.location="newpage.html";}else{ window.history.go(-1); window.history.go(-1);}//--></SCRIPT></HEAD><BODY><P></BODY></HTML> Figure Figure Knuckles Returns the user’s choice of action in response to the message (true=OK, false=CANCEL) Instructs the window object to go to the specified URL Instructs the window object to go to the previous URL stored in the history object

9 PopUp Windows! <HTML><HEAD> Figure Figure <!-- newWindow=window.open("secondpage.html","newWin","width=300, height=300"); //--></SCRIPT></HEAD> I am the page containing the script that caused I am the page containing the script that caused the new window to appear. the new window to appear. </BODY></HTML> Figure Figure Knuckles

10 HTML Forms – Event Handling (Ch.13) An event occurs when an input is sensed by the browser window (by user, clock, operating system) An event occurs when an input is sensed by the browser window (by user, clock, operating system) Event handlers execute code to deal with events – eg. a button being clicked Event handlers execute code to deal with events – eg. a button being clicked </FORM> Figure 13.1 Knuckles Figure 13.1 Knuckles

11 Example Form Object <HTML><HEAD> <!-- function giveMessage(){ document.messageform.reply.value=document.messageform.fname.value+ document.messageform.reply.value=document.messageform.fname.value+ ", have a nice day!"; ", have a nice day!";}//--></SCRIPT></HEAD> Please enter your first name: Please enter your first name: </FORM></BODY></HTML> Example of Figure 13b

12 Additional Examples Using local variables in a function Using local variables in a function –Simple calulator Figure 13.6 Figure 13.6Figure 13.6 Using global variables in a funtion Using global variables in a funtion –Count the clicks Figure 13.7 Figure 13.7Figure 13.7 Contact entry Figure 13.9 Contact entry Figure 13.9Figure 13.9Figure 13.9 –Reducing code size with the with statement –Organizing forms with tables –Verification of text input

13 Other FORM Input Methods (Ch.14) Checkbox Checkbox –Pet food (Figure 14.1) Figure 14.1Figure 14.1 –With hidden values (Figure 14.4) Figure 14.4Figure 14.4 Radio Buttons Radio Buttons –More pet food (Figure 14.7) Figure 14.7Figure 14.7 –Makes use of the element array Pull-Down Menu Pull-Down Menu –Select a background colour (Figure 14.9) Figure 14.9Figure 14.9 –Verify selection made (Section 14.7) Section 14.7Section 14.7

14 Example Survey Form The Sodexo Food survey The Sodexo Food survey The Sodexo Food survey The Sodexo Food survey

15 Resources

16 THE END