Event Driven Programming & User Defined Functions

Slides:



Advertisements
Similar presentations
Computer and Communication Fundamental Basic web programming Lecture 8 Rina Zviel-Girshin.
Advertisements

The Web Warrior Guide to Web Design Technologies
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 7 Event-Driven.
CIS101 Introduction to Computing Week 10 Spring 2004.
Computer Science 103 Chapter 4 Advanced JavaScript.
CIS101 Introduction to Computing Week 10. Agenda Your questions Final exam and final project CIS101 Student Survey Class presentations: Your Mad Libs.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
Lesson 8 Creating Forms 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.,
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.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Event and Event Handling.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JavaScript Part 1.
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.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
1 Functions Lecfture Abstraction abstraction is the process of ignoring minutiae and focusing on the big picture in modern life, we are constantly.
Computers and Scientific Thinking David Reed, Creighton University Functions and Libraries 1.
PHP Form Introduction Getting User Information Text Input.
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
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Scripting and Interactivity 이병희
JavaScript, Fourth Edition
Introduction To JavaScript. Putting it Together (page 11) All javascript must go in-between the script tags. All javascript must go in-between the script.
ECA 225 Applied Interactive Programming ECA 225 Applied Online Programming control structures, events, objects.
IS2802 Introduction to Multimedia Applications for Business Lecture 3: JavaScript and Functions Rob Gleasure
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
Unit 2 — The Exciting World of JavaScript Lesson 7 — Creating Forms with JavaScript.
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
Event Handling (the right way). A Simple Web Page Events - Summary The web page looks like this:
Understanding JavaScript and Coding Essentials Lesson 8.
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.
1 Lesson 6 Introducing JavaScript HTML and JavaScript BASICS, 4 th Edition.
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.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
REEM ALMOTIRI Information Technology Department Majmaah University.
Third lecture Event 27/2/2016 JavaScript Tutorial.
Java Script Introduction. Java Script Introduction.
Event-Driven Programming
JavaScript is a programming language designed for Web pages.
© 2015, Mike Murach & Associates, Inc.
Chapter 8: Writing Graphical User Interfaces
JavaScript.
Barb Ericson Georgia Institute of Technology May 2006
JavaScript Functions.
JAVASCRIPTS AND HTML DOCUMENTS
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript Events.
DHTML Javascript Internet Technology.
WEB PROGRAMMING JavaScript.
Chapter 4 JavaScript and Dynamic Web Pages
Events Comp 205 Fall 2017.
DHTML Javascript Internet Technology.
Chapter 6 Event-Driven Pages
Functions, Regular expressions and Events
Web Design and Development
JavaScript Basics What is JavaScript?
Chapter 7 Event-Driven Pages
JavaScript and Ajax (JavaScript Events)
Introduction to Web programming
Presentation transcript:

Event Driven Programming & User Defined Functions Erdal Kose Cc3.12 Lecture 10

Objectives Event Driven Pages Event Handler User Defined Functions

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., you enter credit card information in a form and submit it pages that respond to user actions such as mouse clicks or form entries are known as event-driven pages JavaScript code can be combined with HTML elements such as buttons, text fields, and text areas to produce event-driven pages

Event Handler an event handler is an HTML element that can be programmed to respond to a user’s actions the simplest event handler is a button a button can be associated with JavaScript code that will execute when the button is clicked general form of a button element: <input type="button" value="BUTTON_LABEL" onclick="JAVASCRIPT_CODE" /> the TYPE attribute of the INPUT element identifies the element to be a button the VALUE attribute specifies the text label that appears on the button the ONCLICK attribute specifies the action to take place any JavaScript statement(s) can be assigned to the ONCLICK attribute this can be (and frequently is) a call to a JavaScript function

Cont.. onclick event-handler is normally assigned in the button’s HTML <input> tag with the HTML onclick attribute <input type=“button” value= Do Click” onclick=“alert(‘ this is cc3.12’)” /> onMouseOver Whenever the user moves mouse over the event-handler a onMouseOver event accurs.

onMouseOut: Whenever the user moves mouse off the event-handler a onMouseOut event accurs Example: <html> <head><title>event-handler</title> </head> <body> <p> <img src=“image.jpg” name=“test_image” onMouseOver=“test_image.src=‘image_1.gif'; return true" onMouseOut =“test_imag.src=‘image_3.gif'; return true" /> </p> </body> </html>

More Example <html> <head> </head> <body> <p> <a href="#" onMouseOver="document.bgColor='red'; return true" onMouseOut ="document.bgColor='white'; return true" > Watch me! </a> </p> </body> </html>

User Defined Functions A function is a piece of JavaScript code that can be executed once or many times by the JavaScript application a function encapsulates some computation & hides the details from the user Create a new function using the JavaScript function keyword User Defined Function are functions that designed by users Pre-defined Functions are functions that designed by JavaScript.

General Function Format to write general-purpose functions, we can extend definitions to include: 1) parameters, 2) local variables, and 3) return statements parameters are variables that correspond to the function’s inputs (if any) parameters appear in the parentheses, separated by commas local variables are temporary variables that are limited to that function only if require some temporary storage in performing calculations, then declare local variables using the keyword var, separated by commas a local variable exists only while the function executes, so no potential conflicts with other functions a return statement is a statement that specifies an output value consists of the keyword return followed by a variable or expression