JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.

Slides:



Advertisements
Similar presentations
JavaScript Objects - DOM CST 200 JavaScript. Objectives Introduce JavaScript objects Introduce Document Object Model Introduce window object Introduce.
Advertisements

 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
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.
Georgia Institute of Technology JavaScript part 2 Barb Ericson Georgia Institute of Technology May 2006.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 7 Event-Driven.
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.
Lesson 8 Creating Forms with JavaScript
CST JavaScript Validating Form Data with JavaScript.
Web Programming Material From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web 1 Introduction The JavaScript Programming.
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.,
4.1 JavaScript Introduction
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.
HTML Forms/Events (Instructor Lesson) The Event model HTML Forms Custom Events 1.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Event and Event Handling.
Introduction to JavaScript. JavaScript Facts A scripting language - not compiled but interpreted line by line at run-time. Platform independent. It is.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
Intro to JavaScript. Use the tag to tell the browser you are writing 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.
Using Client-Side Scripts to Enhance Web Applications 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
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,
JavaScript - A Web Script Language Fred Durao
PHP Form Introduction Getting User Information Text Input.
Button and Textbox. Input  Input objects are used to obtain input from the user viewing the webpage. They allow the user to interact with the Web. 
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
1 JavaScript
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Dialog boxes in JavaScript Events in JavaScript – What are they – “Which events are there?” – “How do I register event handlers to an HTML element?” –
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
JavaScript, Fourth Edition
Event-Driven Programming Chapter Page Section: Section or division of an HTML page Generic block element Example: What's the difference between.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
JavaScript Challenges Answers for challenges
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing a Line of Text in a Web Page 7.3 Another JavaScript.
Project Two Adding Scrolling Messages! Page 2.4 to 2.18 Today’s Agenda Look at scrolling message coding. Create a web page with a text box. Create a web.
Event Handling (the right way). A Simple Web Page Events - Summary The web page looks like this:
Understanding JavaScript and Coding Essentials Lesson 8.
HTML DOM Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
JavaScript Event Handlers. Introduction An event handler executes a segment of a code based on certain events occurring within the application, such as.
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.
 ASP.NET provides an event based programming model that simplifies web programming  All GUI applications are incomplete without enabling actions  These.
CSC 121 Computers and Scientific Thinking Fall Event-Driven Programming.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript 101 Lesson 6: Introduction to Functions.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Popup Boxes.
JavaScript JavaScript is a programming language that web browsers understand. You can use it to make your web pages interactive by: Responding to user.
WEB SYSTEMS & TECHNOLOGY. Java Script  JavaScript created by Netscape  It is also client side programming  It can be use for client side checks.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
Event-Driven Programming
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
JavaScript (JS) Basics
Event Driven Programming & User Defined Functions
Events Comp 205 Fall 2017.
Chapter 6 Event-Driven Pages
Functions, Regular expressions and Events
Web Design and Development
Web Programming and Design
Presentation transcript:

JavaScript Events

Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the user You can think of an event as a trigger that fires a specific JavaScript code in response to a given situation You can think of an event as a trigger that fires a specific JavaScript code in response to a given situation Examples Examples When a user clicks a button When a user clicks a button When a mouse travels over an area and it changes When a mouse travels over an area and it changes When a user enters in information When a user enters in information

HTML Tags and Events The most commonly used html tag that allows the to generate an event is a tag The most commonly used html tag that allows the to generate an event is a tag The input tag allows the user to interact with the page by typing in info or selecting an item The input tag allows the user to interact with the page by typing in info or selecting an item An input tag is created inside of a form tag and contains a “type” attribute which specifies the type of input An input tag is created inside of a form tag and contains a “type” attribute which specifies the type of input creates a text field creates a text field

Tags Tags age age 15-20

Event Handlers When an event occurs, a program executes JavaScript code that responds to the event When an event occurs, a program executes JavaScript code that responds to the event The code that executes because of an event is called an event handler The code that executes because of an event is called an event handler An example of an event handler is when the user clicks on a button and something happens because the button was clicked An example of an event handler is when the user clicks on a button and something happens because the button was clicked Two things that can occur on the click of a button is an alert display or a prompt display Two things that can occur on the click of a button is an alert display or a prompt display

Alert Display The alert method displays a pop-up dialog box with an OK button The alert method displays a pop-up dialog box with an OK button You can pass a single literal string or variable as an argument You can pass a single literal string or variable as an argument The literal string is contained inside single quotations, a variable is not placed inside quotes The literal string is contained inside single quotations, a variable is not placed inside quotes Onclick, Value, & Type are all attributes to the input tag Onclick, Value, & Type are all attributes to the input tag

Prompt Display Prompt method displays a pop-up dialog box with a message, a text box, an OK button, and a Cancel button Prompt method displays a pop-up dialog box with a message, a text box, an OK button, and a Cancel button Any text that is entered into the text box can be assigned to a variable Any text that is entered into the text box can be assigned to a variable The syntax for a prompt method is… The syntax for a prompt method is… variable_name=prompt(“message”, “default_text”); variable_name=prompt(“message”, “default_text”); Example Example var Age=prompt(“How old are you?”, “enter age”); var Age=prompt(“How old are you?”, “enter age”);

Prompt Method Now a value is assign to a variable, and an alert can now display the variable Now a value is assign to a variable, and an alert can now display the variable alert(‘Your age is’ + Age); alert(‘Your age is’ + Age); But in order to enter the amount into the prompt, the button must activate a function that contains the prompt and the alert But in order to enter the amount into the prompt, the button must activate a function that contains the prompt and the alert The onclick attribute is used to call the function, and then the function will display the prompt and the alert The onclick attribute is used to call the function, and then the function will display the prompt and the alert

Example JS Events JS Events function myage() { function myage() { var age=prompt(“How old are you?", "enter age"); var age=prompt(“How old are you?", "enter age"); alert('Your age is ' + age);} alert('Your age is ' + age);}